Skip to content

Commit

Permalink
Add support for commiting terraform outputs and skipping terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Feb 2, 2024
1 parent 417d727 commit 1314557
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ on:
# - 'tf/environments/production/**'
env:
tf_actions_working_dir: "./tf/environments/production"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
terraform:
runs-on: ubuntu-latest
if: ${{ !startsWith(github.event.head_commit.message, 'skip-terraform:') }}
defaults:
run:
working-directory: ${{ env.tf_actions_working_dir }}

permissions:
pull-requests: write
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_VAR_aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
TF_VAR_aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_VAR_datadog_api_key: ${{ secrets.DATADOG_API_KEY}}
Expand Down Expand Up @@ -62,6 +63,17 @@ jobs:
echo "EOF" >> "$GITHUB_OUTPUT"
continue-on-error: true

- name: Commit and Push Terraform Outputs
id: commit
run: |
echo "git_commit<<EOF" >> "$GITHUB_OUTPUT"
git config --global user.email "nothuman@ooni.org"
git config --global user.name "OONI Github Actions Bot"
git add ${{ env.tf_actions_working_dir }} >> "$GITHUB_OUTPUT"
git commit -m "skip-terraform: autoupdate terraform outputs" || echo "No changes to commit" >> "$GITHUB_OUTPUT"
git push origin HEAD:${{ github.head_ref }} >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -98,6 +110,16 @@ jobs:
</details>
#### Commit \`${{ steps.apply.outcome }}\`
<details><summary>Show Commit</summary>
\`\`\`\n
${{ steps.commit.outputs.git_commit }}
\`\`\`
</details>
| | |
|-------------------|-----------------------------------|
| Pusher | @${{ github.actor }} |
Expand Down

0 comments on commit 1314557

Please sign in to comment.