Merge pull request #25 from a-company-jp/add-nginx-gha #1
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: Build&Push Nginx image to GAR | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'docker/nginx/**' | |
- '.github/workflows/deploy-nginx.yaml' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
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/228944830644/locations/global/workloadIdentityPools/gh-pool/providers/provider-github' | |
service_account: '[email protected]' | |
- 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: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: asia-northeast1-docker.pkg.dev/lgtmgen-project/dev-main/nginx:latest | |
file: ./docker/nginx/Dockerfile | |
context: ./docker/nginx |