Skip to content

Detect drift

Detect drift #948

name: Detect drift
on:
workflow_dispatch:
inputs: {}
schedule:
# hourly
- cron: '0 * * * *'
jobs:
pick-out-drift-issues:
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: read
issues: write # To close issues
outputs:
issues: ${{steps.pick-out-drift-issues.outputs.issues}}
has_issues: ${{steps.pick-out-drift-issues.outputs.has_issues}}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: aquaproj/aqua-installer@e6160e5a751bbcbd337a834eb75c15ba9ca206ae # v3.0.2
with:
aqua_version: v2.37.2
env:
AQUA_GITHUB_TOKEN: ${{github.token}}
- run: tfaction pick-out-drift-issues
id: pick-out-drift-issues
env:
GITHUB_TOKEN: ${{github.token}}
detect-drift:
timeout-minutes: 30
name: "detect-drift (${{matrix.issue.target}})"
runs-on: ${{matrix.issue.runs_on}}
needs: pick-out-drift-issues
permissions:
issues: write # For github-comment and tfcmt
contents: write # To push commits
id-token: write # For OIDC
if: fromJSON(needs.pick-out-drift-issues.outputs.has_issues)
strategy:
fail-fast: false
matrix:
issue: ${{fromJSON(needs.pick-out-drift-issues.outputs.issues)}}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{secrets.APP_ID}}
private_key: ${{secrets.APP_PRIVATE_KEY}}
# issues:write - Create and update issues
permissions: >-
{
"issues": "write"
}
# issues of Drift Detection
repositories: >-
[
"tfaction-example"
]
- uses: aquaproj/aqua-installer@e6160e5a751bbcbd337a834eb75c15ba9ca206ae # v3.0.2
with:
aqua_version: v2.37.2
env:
GITHUB_TOKEN: ${{github.token}}
- uses: suzuki-shunsuke/tfaction/set-drift-env@2b9d52f60b37e9331ebfe8f06df7ec2d0ee493a6 # v1.12.1
with:
issue: ${{toJSON(matrix.issue)}}
- uses: suzuki-shunsuke/tfaction/setup@2b9d52f60b37e9331ebfe8f06df7ec2d0ee493a6 # v1.12.1
with:
github_token: ${{steps.generate_token.outputs.token}}
env:
GITHUB_TOKEN: ${{steps.generate_token.outputs.token}}
TF_TOKEN_app_terraform_io: ${{secrets.TFE_TOKEN}} # For Hashicorp Cloud Backend
- uses: suzuki-shunsuke/tfaction/test@2b9d52f60b37e9331ebfe8f06df7ec2d0ee493a6 # v1.12.1
with:
github_token: ${{steps.generate_token.outputs.token}}
env:
GITHUB_TOKEN: ${{steps.generate_token.outputs.token}}
- uses: suzuki-shunsuke/tfaction/terraform-plan@2b9d52f60b37e9331ebfe8f06df7ec2d0ee493a6 # v1.12.1
with:
github_token: ${{steps.generate_token.outputs.token}}
env:
GITHUB_TOKEN: ${{steps.generate_token.outputs.token}}
TF_TOKEN_app_terraform_io: ${{secrets.TFE_TOKEN}} # For Hashicorp Cloud Backend
TFE_TOKEN: ${{secrets.TFE_TOKEN}} # For tfe provider
- uses: suzuki-shunsuke/tfaction/update-drift-issue@2b9d52f60b37e9331ebfe8f06df7ec2d0ee493a6 # v1.12.1
if: always()
with:
status: ${{job.status}}
github_token: ${{steps.generate_token.outputs.token}}