diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 8580a0b03..4f22ab7f0 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -18,6 +18,14 @@ jobs: steps: - uses: actions/checkout@v2 + + - name: Set docker image tags + id: set-tags + run: | + set -a; source .env; set +a + echo "SERVER_IMAGE_TAG=${SERVER_IMAGE_TAG}" >> "$GITHUB_OUTPUT" + echo "Current server image tag (push): ${SERVER_IMAGE_TAG}" + - name: docker login run: | # log into docker hub account docker login -u $DOCKER_USER -p $DOCKER_PASSWORD @@ -40,6 +48,22 @@ jobs: run: | docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} + - name: Update .env file + run: | + echo "SERVER_IMAGE_TAG=${GITHUB_REF##*/}_${{ steps.date.outputs.date }}" > .env + + - name: Add, Commit, Push changes to .env file + run: | + git config --local user.email "action@github.com" + git config --local user.name "Github Actions bot to update .env with latest tags" + if git diff --quiet; then + echo "Latest timestamp already present in .env file, no changes to commit" + else + git add .env + git commit -m "Updated docker image tags in .env file to the latest timestamp" + git push origin + fi + - name: Create a text file run: | echo ${{ steps.date.outputs.date }} > tag_file.txt @@ -56,9 +80,6 @@ jobs: needs: build runs-on: ubuntu-latest - env: - DOCKER_IMAGE_TAG: ${{ needs.build.outputs.date }} - strategy: matrix: include: @@ -71,7 +92,6 @@ jobs: - uses: actions/checkout@v4 - name: Trigger workflow in admin-dash, public-dash - # TODO: Create Fine-grained token with "Actions: write" permissions run: | curl -L \ -X POST \ @@ -79,4 +99,4 @@ jobs: -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":"${{ matrix.branch }}", "inputs": {"docker_image_tag" : "${{ env.DOCKER_IMAGE_TAG }}"}}' + -d '{"ref":"${{ matrix.branch }}"}'