-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: contribution details, prod workflow uses prepyrus, updated PR…
… template
- Loading branch information
Showing
8 changed files
with
209 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,111 @@ | ||
name: Deploy to Production | ||
|
||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [created] | ||
workflow_dispatch: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build_and_deploy: | ||
if: github.repository_owner == 'systemphil' | ||
environment: prod | ||
runs-on: ubuntu-latest | ||
env: | ||
PROJECT_ID: ${{ secrets.PROJECT_ID }} | ||
SERVICE: ${{ secrets.SERVICE }} | ||
REGION: ${{ secrets.REGION }} | ||
TAG: latest | ||
|
||
steps: | ||
- name: Check if running in the parent repository | ||
run: | | ||
if [ "${GITHUB_REPOSITORY}" != "systemphil/sphil" ]; then | ||
echo "This workflow is only intended for the parent repository. Skipping deployment." | ||
exit 1 | ||
fi | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Auth | ||
uses: "google-github-actions/auth@v2" | ||
with: | ||
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" | ||
|
||
- name: Docker Auth | ||
id: docker-auth | ||
uses: "docker/login-action@v1" | ||
with: | ||
username: _json_key | ||
password: "${{ secrets.GOOGLE_CREDENTIALS }}" | ||
registry: "${{ env.REGION }}-docker.pkg.dev" | ||
|
||
- name: Build and Push Container | ||
# NEXT_PUBLIC_ env variables have to be set during the build phase. | ||
run: |- | ||
docker build \ | ||
--build-arg NEXT_PUBLIC_SITE_ROOT=${{secrets.NEXT_PUBLIC_SITE_ROOT}} \ | ||
--build-arg NEXT_PUBLIC_GA_ID=${{secrets.NEXT_PUBLIC_GA_ID}} \ | ||
-f Dockerfile \ | ||
-t "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" ./ | ||
docker push "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" | ||
- name: Deploy to Cloud Run | ||
run: | | ||
gcloud run deploy ${{env.SERVICE}} \ | ||
--platform=managed \ | ||
--region=${{ env.REGION }} \ | ||
--max-instances=4 \ | ||
--min-instances=default \ | ||
--image="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" | ||
prepyrus_verify: | ||
if: github.repository_owner == 'systemphil' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache/restore@v4 | ||
id: prepyrus-cache-restore | ||
with: | ||
path: target/release/prepyrus | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('scripts/prepyrus/Cargo.lock') }}-${{ hashFiles('scripts/prepyrus/src/**') }} | ||
|
||
- name: Install Rust | ||
if: steps.prepyrus-cache-restore.outputs.cache-hit != 'true' | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
|
||
- name: Install dependencies | ||
if: steps.prepyrus-cache-restore.outputs.cache-hit != 'true' | ||
run: cargo build --release --package prepyrus | ||
|
||
- name: Run prepyrus script in VERIFY mode | ||
run: target/release/prepyrus absolute_bibliography.bib src/pages verify | ||
|
||
- name: Upload prepyrus for next job | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: prepyrus_artifact | ||
path: target/release/prepyrus | ||
|
||
- name: Save Prepyrus to cache | ||
id: prepyrus-cache-save | ||
if: steps.prepyrus-cache-restore.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: target/release/prepyrus | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('scripts/prepyrus/Cargo.lock') }}-${{ hashFiles('scripts/prepyrus/src/**') }} | ||
|
||
build_and_deploy: | ||
needs: prepyrus_verify | ||
if: github.repository_owner == 'systemphil' | ||
environment: prod | ||
runs-on: ubuntu-latest | ||
env: | ||
PROJECT_ID: ${{ secrets.PROJECT_ID }} | ||
SERVICE: ${{ secrets.SERVICE }} | ||
REGION: ${{ secrets.REGION }} | ||
TAG: latest | ||
|
||
steps: | ||
- name: Check if running in the parent repository | ||
run: | | ||
if [ "${GITHUB_REPOSITORY}" != "systemphil/sphil" ]; then | ||
echo "This workflow is only intended for the parent repository. Skipping deployment." | ||
exit 1 | ||
fi | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Download prepyrus artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: prepyrus_artifact | ||
path: target/release/prepyrus | ||
|
||
- name: Give execution permissions to prepyrus | ||
run: chmod +x target/release/prepyrus/prepyrus | ||
|
||
- name: Run prepyrus in PROCESS mode | ||
run: target/release/prepyrus/prepyrus absolute_bibliography.bib src/pages process | ||
|
||
- name: Auth | ||
uses: "google-github-actions/auth@v2" | ||
with: | ||
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" | ||
|
||
- name: Docker Auth | ||
id: docker-auth | ||
uses: "docker/login-action@v1" | ||
with: | ||
username: _json_key | ||
password: "${{ secrets.GOOGLE_CREDENTIALS }}" | ||
registry: "${{ env.REGION }}-docker.pkg.dev" | ||
|
||
- name: Build and Push Container | ||
# NEXT_PUBLIC_ env variables have to be set during the build phase. | ||
run: |- | ||
docker build \ | ||
--build-arg NEXT_PUBLIC_SITE_ROOT=${{secrets.NEXT_PUBLIC_SITE_ROOT}} \ | ||
--build-arg NEXT_PUBLIC_GA_ID=${{secrets.NEXT_PUBLIC_GA_ID}} \ | ||
-f Dockerfile \ | ||
-t "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" ./ | ||
docker push "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" | ||
- name: Deploy to Cloud Run | ||
run: | | ||
gcloud run deploy ${{env.SERVICE}} \ | ||
--platform=managed \ | ||
--region=${{ env.REGION }} \ | ||
--max-instances=4 \ | ||
--min-instances=default \ | ||
--image="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# sPhil's Bibliography | ||
|
||
_work in progress_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.