Skip to content

Commit

Permalink
Merge pull request #4 from MukuFlash03/tags-combo-approach
Browse files Browse the repository at this point in the history
Image tag passing with matrix strategy + artifact method
  • Loading branch information
nataliejschultz authored May 6, 2024
2 parents a0190d4 + f306e8c commit 00d9565
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .docker/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Temporary test file while working on automating tags modification.
Checking to see if new artifacts generated even if overwrite is set to true.

-----

Testing again to see if workflow dispatch works

Yes, working with updated branch as well.
------

Testing if working with updated token scopes to have only actions: write

-----

Testing to see if matrix build dispatch strategy works again.

-----
44 changes: 43 additions & 1 deletion .github/workflows/image_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ name: docker image
# events but only for the master branch
on:
push:
# TODO: Change branch to master branch of e-mission-server
branches: [ consolidate-differences ]


# Env variable
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
Expand All @@ -21,6 +21,9 @@ jobs:
# The type of runner that the job will run on
runs-on: ubuntu-latest

outputs:
date: ${{ steps.date.outputs.date }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand All @@ -46,3 +49,42 @@ jobs:
- name: push docker image
run: |
docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }}
- name: Create a text file
run: |
echo ${{ steps.date.outputs.date }} > tag_file.txt
echo "Created tag text file"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: docker-image-tag
path: tag_file.txt
overwrite: true

dispatch:
needs: build
runs-on: ubuntu-latest

env:
DOCKER_IMAGE_TAG: ${{ needs.build.outputs.date }}

strategy:
matrix:
# TODO: Change user / organization to emission instead of MukuFlash03
repo: ['MukuFlash03/op-admin-dashboard', 'MukuFlash03/em-public-dashboard']

steps:
- uses: actions/checkout@v4

- name: Trigger workflow in admin-dash, public-dash
# TODO: Create Fine-grained token with "Actions: write" permissions
# TODO: Change branch name under "ref" in the curl command
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_FG_PAT_TAGS }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ matrix.repo }}/actions/workflows/image_build_push.yml/dispatches \
-d '{"ref":"tags-combo-approach", "inputs": {"docker_image_tag" : "${{ env.DOCKER_IMAGE_TAG }}"}}'

0 comments on commit 00d9565

Please sign in to comment.