Skip to content

Commit

Permalink
fix workflow job trigger condition
Browse files Browse the repository at this point in the history
  • Loading branch information
uche-madu committed Sep 30, 2023
1 parent b5159a8 commit 5040e48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/retag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: >
the Infrastructure Repository
on:
pull_request:
push:
branches:
- main
types:
Expand All @@ -12,7 +12,6 @@ on:
- 'Dockerfile'
- 'requirements.txt'


env:
PROJECT_ID: wizeline-deb
GAR_LOCATION: us-central1
Expand All @@ -21,7 +20,6 @@ env:

jobs:
retag_and_push:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

permissions:
Expand Down Expand Up @@ -52,11 +50,22 @@ jobs:
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'

- name: Get last merged PR source branch name
id: get-branch-name
run: |
PR_NUMBER=$(gh pr list --base main --state closed --limit 1 --json number -q ".[0].number")
FEATURE_BRANCH_NAME=$(gh pr view $PR_NUMBER --json headRefName -q ".headRefName")
echo "Last merged PR number: $PR_NUMBER"
echo "Source branch name: $FEATURE_BRANCH_NAME"
echo "FEATURE_BRANCH_NAME=$FEATURE_BRANCH_NAME" >> $GITHUB_ENV
env:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Retag Docker Image
run: |
echo "SHORT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV
docker pull "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_HEAD_REF"
docker tag "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_HEAD_REF" "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$SHORT_SHA"
docker pull "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$FEATURE_BRANCH_NAME"
docker tag "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$FEATURE_BRANCH_NAME" "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$SHORT_SHA"
docker push "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$SHORT_SHA"
# Clone the values file from the infrastructure repository
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /usr/local/airflow

COPY requirements.txt .

# install dbt into a virtual environment to use external python operator
# Install dbt into a virtual environment to use the ExternalPythonOperator
# The sed command allows pip to avoid running with --user flag
RUN python -m venv dbt_venv && \
sed -i 's/include-system-site-packages = false/include-system-site-packages = true/' dbt_venv/pyvenv.cfg && \
Expand Down

0 comments on commit 5040e48

Please sign in to comment.