testing push to gcp #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: Push to Artifact Registry | |
on: | |
push: | |
branches: [ "master" ] | |
env: | |
IMAGE_NAME: 'welcome-technical-challenge' | |
PROJECT_ID: 'k8s-hackaton' | |
AR_REPO_LOCATION: 'europe-north1' | |
AR_URL: 'europe-north1-docker.pkg.dev/k8s-hackaton/k8-hackaton' | |
SERVICE_ACCOUNT: '[email protected]' | |
WORKLOAD_IDENTITY_PROVIDER: 'projects/1038165701297/locations/global/workloadIdentityPools/my-app-dev-pool/providers/github-actions-provider' | |
jobs: | |
push_to_ar: | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Google Auth | |
id: auth | |
uses: 'google-github-actions/auth@v2' | |
with: | |
token_format: 'access_token' | |
project_id: ${{ env.PROJECT_ID }} | |
service_account: ${{ env.SERVICE_ACCOUNT }} | |
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} | |
- name: Docker Auth | |
id: docker-auth | |
uses: 'docker/login-action@v1' | |
with: | |
username: 'oauth2accesstoken' | |
password: '${{ steps.auth.outputs.access_token }}' | |
registry: '${{ env.AR_REPO_LOCATION }}-docker.pkg.dev' | |
- name: Build and Push Container | |
run: |- | |
docker build -t "${{ env.AR_URL }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" ./ | |
docker push "${{ env.AR_URL }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" |