From 571e861f628ffd90e376d1123a88a16d53808d02 Mon Sep 17 00:00:00 2001 From: Andrew Dryga Date: Mon, 12 Jun 2023 14:52:50 -0600 Subject: [PATCH] Try pushing update using GH API --- .github/workflows/cd.yml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d75d8491a..0d18dd055 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -42,16 +42,27 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.event.workflow_run.head_branch }} - - name: "Update Application Tags" + - name: "Push Changed Application Tags" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FILE_TO_COMMIT: terraform/environments/staging/versions.auto.tfvars + DESTINATION_BRANCH: ${{ github.event.workflow_run.head_branch }} run: | sed -ri 's/^(\s*)(api_image_tag\s*=\s*"[^"]*"\s*$)/api_image_tag = "${{ github.sha }}"/' ./terraform/environments/staging/versions.auto.tfvars sed -ri 's/^(\s*)(web_image_tag\s*=\s*"[^"]*"\s*$)/web_image_tag = "${{ github.sha }}"/' ./terraform/environments/staging/versions.auto.tfvars cat ./terraform/environments/staging/versions.auto.tfvars - git config --global user.name 'GitHub Action' - git config --global user.email 'github_actions@firez.one' - git add terraform/environments/staging/versions.auto.tfvars - git commit -m "Push updated container versions" - git push + + export TODAY=$( date -u '+%Y-%m-%d' ) + export SHA=$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT ) + export CONTENT=$( base64 -i $FILE_TO_COMMIT ) + + gh api \ + --method PUT /repos/${{ github.repository }}/contents/$FILE_TO_COMMIT \ + --field message="Push updated container versions [skip actions]" \ + --field content="$CONTENT" \ + --field encoding="base64" \ + --field branch="$DESTINATION_BRANCH" \ + --field sha="$SHA" - name: Upload Configuration uses: hashicorp/tfc-workflows-github/actions/upload-configuration@v1.0.0 id: apply-upload