Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release workflowのTriggerを変更 #125

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions .github/workflows/deploy-cloudrun-release.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Deploy to Cloud Run (Release)
on:
push:
branches:
- release
release:
types:
- released
jobs:
build-and-deploy:
runs-on: ubuntu-latest
Expand All @@ -12,59 +12,49 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
token_format: access_token
workload_identity_provider: 'projects/292061085119/locations/global/workloadIdentityPools/github-pool/providers/provider-github'
service_account: '[email protected]'

- name: Set up Cloud SDK
uses: 'google-github-actions/setup-gcloud@v2'
with:
version: '>= 363.0.0'

- name: Authorize Docker
id: docker-auth
uses: docker/login-action@v3
with:
username: 'oauth2accesstoken'
password: ${{ steps.auth.outputs.access_token }}
registry: asia-northeast1-docker.pkg.dev

- name: Configure .env
run: |
echo "IS_PRODUCTION=true" >> .env
echo "CONTEST_DATA_URL=${{ secrets.CONTEST_DATA_URL }}" >> .env

- name: Download events.json from external URL
run: |
curl "${{ secrets.EVENTS_COMPLETE_URL }}" -o ./assets/data/events-detail.json
curl "${{ secrets.EVENTS_SUMMARY_URL }}" -o ./assets/data/events.json

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: asia-northeast1-docker.pkg.dev/ynufes-hp-cloudrun/release/tokiwa23:latest
context: .
file: ./cloudrun/Dockerfile

- name: Download Cloud Run Service YAML
run: |
gcloud run services describe hp-main --format yaml --region asia-northeast1 > ./cloudrun/service-hp-main.yaml

# replace github_sha field to latest commit sha. Changing spec.template is required to deploy new revision.
# reference: https://cloud.google.com/run/docs/deploying?hl=ja#revision -- check yaml tab.
- name: Change some property of service-hp-main.yaml
run: |
sed -i "s/github_sha: .*/github_sha: ${{ github.sha }}/g" ./cloudrun/service-hp-main.yaml

- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v2
Expand Down
Loading