Skip to content

Commit

Permalink
Dispatch job on push:tag + Remaining steps on either tags or dispatch
Browse files Browse the repository at this point in the history
Latest runs observations.
- Passed for server, join, admin-dash, public-dash.
- Failed for admin-dash, public-dash.
- Workflow dispatch occurred twice since the server build job was a dependency for dispatch job and we removed ref_type == tag check.
- To prevent dispatch occurring twice, need to add ref_type check to dispatch job in server workflow.
    - This caused dispatch to be triggered even for push:branch event on server.
    - But this doesn’t update version tag so even with dispatch, the dashboard workflows should have used the current non-updated server tag.
    - But during testing I immediately also create a new release with a new tag, and the reusable workflow fetches tags from GitHub REST API.
        - So even though push:branch event didn’t update server tag, my manual UI tag creation already updated it.
        - This caused the dispatch events that were triggered on push:branch in dashboards to pick up the latest UI tag.
        - But this fails since this image was never pushed since we only push on push:tags event.
    - In parallel, server workflow for push:tags had already started running as well and this did push the server image with latest new tag created through UI.
- However, for workflow dispatch events as well the remaining steps were skipped since workflow_dispatch also has a ref_type: branch.
    - Hence need to add OR condition that checks for both ref_type: tags (in case of push:tags event) as well as event_name: workflow_dispatch for dashboard workflows triggered on server push:tag only.
  • Loading branch information
MukuFlash03 committed Oct 7, 2024
1 parent 8863d92 commit 028960b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/image_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
secrets: inherit

dispatch:
if: ${{ github.ref_type == 'tag' }}
needs: [build]
runs-on: ubuntu-latest

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/reusable_image_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ jobs:
docker images
- name: rename docker image
if: ${{ github.ref_type == 'tag' }}
if: ${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
run: |
if [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then
if [ "${{ github.event_name }}" == "push" ]; then
Expand All @@ -223,7 +223,7 @@ jobs:
fi
- name: push docker image
if: ${{ github.ref_type == 'tag' }}
if: ${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
run: |
if [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then
if [ "${{ github.event_name }}" == "push" ]; then
Expand All @@ -249,7 +249,7 @@ jobs:
fi
- name: Update .env file
if: ${{ github.ref_type == 'tag' }}
if: ${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
run: |
if [ "${{ inputs.repo }}" = "e-mission-server" ]; then
echo "SERVER_IMAGE_TAG=${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env
Expand Down Expand Up @@ -289,7 +289,7 @@ jobs:
cat .env
- name: Add, Commit, Push changes to .env file
if: ${{ github.ref_type == 'tag' }}
if: ${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "Github Actions bot to update .env with latest tags"
Expand Down

0 comments on commit 028960b

Please sign in to comment.