-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Github Actions for deployment and releasing
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
env: | ||
PROJECT_NUMBER: ${{ secrets.GCP_PROJECT_NUMBER }} | ||
PROJECT_ID: ${{ secrets.GCP_PROJECT }} | ||
GCR_LOCATION: asia.gcr.io | ||
GCR_REGION: asia-northeast1 | ||
WI_POOL_ID: ${{ secrets.WI_POOL_ID }} | ||
WI_PROVIDER_ID: ${{ secrets.WI_PROVIDER_ID }} | ||
WI_SERVICE_ACCOUNT: ${{ secrets.WI_SERVICE_ACCOUNT }} | ||
LOGBOOK_ATMOS_TOKEN: ${{ secrets.LOGBOOK_ATMOS_TOKEN }} | ||
LOGBOOK_ATMOS_API: ${{ secrets.LOGBOOK_ATMOS_API }} | ||
SERVICE: logbook-api | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Cloud SDK | ||
id: 'auth' | ||
uses: google-github-actions/auth@v0 | ||
with: | ||
create_credentials_file: true | ||
workload_identity_provider: | ||
projects/${{ env.PROJECT_NUMBER }}/locations/global/workloadIdentityPools/${{ env.WI_POOL_ID }}/providers/${{ env.WI_PROVIDER_ID }} | ||
service_account: ${{ env.WI_SERVICE_ACCOUNT }} | ||
|
||
- name: Activate gcloud | ||
run: gcloud auth login --brief --cred-file="${{ steps.auth.outputs.credentials_file_path }}" | ||
|
||
- name: Authorize Docker push | ||
run: gcloud auth configure-docker --quiet | ||
|
||
- name: Build Container Image | ||
run: docker build -t ${{ env.GCR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} . | ||
|
||
- name: Push Container Image | ||
run: docker push ${{ env.GCR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} | ||
|
||
- name: Deploy to Cloud Run | ||
id: deploy | ||
uses: google-github-actions/deploy-cloudrun@v0 | ||
with: | ||
image: ${{ env.GCR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} | ||
project_id: ${{ env.PROJECT_ID }} | ||
region: ${{ env.GCR_REGION }} | ||
service: ${{ env.SERVICE }} | ||
env_vars: LOGBOOK_ATMOS_TOKEN=${{ env.LOGBOOK_ATMOS_TOKEN }},LOGBOOK_ATMOS_API=${{ env.LOGBOOK_ATMOS_API }} | ||
tag: latest | ||
no_traffic: false |
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,29 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --rm-dist |