feature: workflow_dispatch追加 #5
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 }} | |
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: Build image | |
run: docker image build -t asia-northeast1-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 asia-northeast1-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/devlocator-app/devlocator:latest |