fix workflow git push #14
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 Airflow Image with Feature Branch as the Tag | |
on: | |
push: | |
branches-ignore: | |
- main | |
paths: # Only run workflow when Dockerfile or requirements.txt is changed | |
- 'Dockerfile' | |
- 'requirements.txt' | |
env: | |
PROJECT_ID: wizeline-deb | |
GAR_LOCATION: us-central1 | |
REPOSITORY: deb-capstone-airflow-gke | |
IMAGE: airflow2.7.1-custom | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
# Configure Workload Identity Federation and generate an access token. | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
token_format: 'access_token' | |
# Replace with values based on setup.sh in dev-infrastructure repo | |
workload_identity_provider: 'projects/734911192367/locations/global/workloadIdentityPools/deb-pool/providers/github-actions' | |
service_account: '[email protected]' | |
- name: Docker login | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev | |
username: 'oauth2accesstoken' | |
password: '${{ steps.auth.outputs.access_token }}' | |
# Use the branch name as the tag | |
- name: Build and Push Docker Image | |
run: | | |
docker build -t "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:${GITHUB_REF##*/}" . | |
docker push "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:${GITHUB_REF##*/}" |