ci(actions): Bump actions/cache from 3 to 4 #86
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: opentofu/setup-opentofu@v1 | |
with: | |
tofu_version: 1.6.0-alpha5 | |
tofu_wrapper: "false" | |
- name: Format | |
run: tofu fmt -recursive | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: opentofu-fmt | |
path: | | |
./**/*.tf | |
./**/*.tfvars | |
opentofu-lock: | |
name: Lock | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
workspace: ["github", "terraform-cloud"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: opentofu/setup-opentofu@v1 | |
with: | |
tofu_version: 1.6.0-alpha5 | |
tofu_wrapper: "false" | |
- name: Init | |
run: tofu init -backend=false | |
working-directory: ${{ matrix.workspace }} | |
- name: Lock | |
run: tofu providers lock -platform=linux_arm64 -platform=linux_amd64 -platform=darwin_arm64 -platform=darwin_amd64 | |
working-directory: ${{ matrix.workspace }} | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: opentofu-lock-${{ matrix.workspace }} | |
path: ${{ matrix.workspace }}/.terraform.lock.hcl | |
opentofu-result: | |
name: Result | |
runs-on: ubuntu-latest | |
needs: [opentofu-fmt, opentofu-lock] | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: create-github-app-token | |
with: | |
app-id: ${{ secrets.ACTIONS_PYTHON_CI_APP_ID }} | |
private-key: ${{ secrets.ACTIONS_PYTHON_CI_APP_PEM_FILE }} | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.create-github-app-token.outputs.token }} | |
fetch-depth: 0 | |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || '' }} | |
- uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Gather Artifacts | |
id: gather-artifacts | |
run: | | |
find "artifacts/opentofu-fmt" -type f \ | |
| sed "s|artifacts/opentofu-fmt/||g" \ | |
| xargs -I{} mv artifacts/opentofu-fmt/{} {} | |
find "artifacts" -maxdepth 1 -type d \ | |
| grep "opentofu-lock-" \ | |
| sed -e "s|.*/opentofu-lock-||g" \ | |
| xargs -I{} mv artifacts/opentofu-lock-{}/.terraform.lock.hcl {}/.terraform.lock.hcl | |
if [ -n "$(git status --porcelain)" ]; then | |
git status --porcelain | |
git add --all | |
echo "changed=true" >> "$GITHUB_OUTPUT" | |
fi | |
- uses: tyriis/[email protected] | |
if: ${{ steps.gather-artifacts.outputs.changed == 'true' }} | |
with: | |
message: "ci(terraform): Update terraform code" | |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || '' }} | |
token: ${{ steps.create-github-app-token.outputs.token }} |