feat: Add CI for opentofu #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Format | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
types: [opened, reopened, synchronize] | |
jobs: | |
opentofu-fmt: | |
name: Format | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: kislerdm/setup-opentofu@main | |
with: | |
cli_config_credentials_token: ${{ secrets.APP_TERRAFORM_IO_TOKEN }} | |
tofu_version: 1.6.0-alpha1 | |
- name: Format | |
run: tofu fmt -recursive | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: opentofu-fmt | |
path: | | |
github/**/*.tf | |
github/**/*.tfvars | |
opentofu-lock: | |
name: Lock | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
module: ["github"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: kislerdm/setup-opentofu@main | |
with: | |
cli_config_credentials_token: ${{ secrets.APP_TERRAFORM_IO_TOKEN }} | |
tofu_version: 1.6.0-alpha1 | |
- name: Init | |
run: tofu init -backend=false | |
working-directory: ${{ matrix.module }} | |
- name: Lock | |
run: tofu providers lock -platform=linux_arm64 -platform=linux_amd64 -platform=darwin_arm64 -platform=darwin_amd64 | |
working-directory: ${{ matrix.module }} | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: opentofu-lock-${{ matrix.module }} | |
path: ${{ matrix.module }}/.terraform.lock.hcl | |
opentofu-summarize: | |
name: Summarize | |
runs-on: ubuntu-latest | |
needs: | |
- opentofu-fmt | |
- opentofu-lock | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: kislerdm/setup-opentofu@main | |
with: | |
cli_config_credentials_token: ${{ secrets.APP_TERRAFORM_IO_TOKEN }} | |
tofu_version: 1.6.0-alpha1 | |
- uses: actions/download-artifact@v3 | |
- name: Commit and Push | |
run: | | |
git config user.name "actions-python-ci[bot]" | |
git config user.email "147721807+actions-python-ci[bot]@users.noreply.github.com" | |
if [ -n "$(git status --porcelain)" ]; then | |
git add --all | |
git commit -m "ci(terraform): Update terraform code" | |
git push origin HEAD:${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | |
fi |