Merge pull request #25 from takumi-pro/feature/refactor-eventapi #13
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
name: deploy GCP | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
REGION: asia-northeast1 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: build | |
run: go build ./main.go | |
test: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: test | |
run: go test ./... -v | |
build-push-artifact: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: "projects/${{ secrets.GCP_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/github-actions-oidc/providers/github-actions-oidc-provider" | |
service_account: ${{ secrets.GCP_SA_EMAIL }} | |
- name: Configure Docker | |
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev | |
- name: Build image | |
run: docker image build -t ${{ env.REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/devlocator-app/devlocator:latest --target production --platform linux/amd64 -f docker/golang/Dockerfile . | |
- name: Push image | |
run: docker image push ${{ env.REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/devlocator-app/devlocator:latest | |
- name: Deploy to Cloud Run | |
run: |- | |
gcloud run deploy devlocator \ | |
--image ${{ env.REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/devlocator-app/devlocator:latest \ | |
--platform=managed \ | |
--allow-unauthenticated \ | |
--region ${{ env.REGION }} |