diff --git a/.docker/test.txt b/.docker/test.txt new file mode 100644 index 000000000..c640a8df8 --- /dev/null +++ b/.docker/test.txt @@ -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. + +----- \ No newline at end of file diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 9fbaa04f3..aff75e152 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -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}} @@ -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 @@ -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 }}"}}' \ No newline at end of file