Skip to content

feat: add talos_image_id_x86 output for autoscaler snapshot reference #4

feat: add talos_image_id_x86 output for autoscaler snapshot reference

feat: add talos_image_id_x86 output for autoscaler snapshot reference #4

name: Developer Experience
on:
workflow_dispatch:
push:
branches:
- main
- next
pull_request_target:
types:
- opened
- synchronize
- reopened
- edited
branches:
- main
permissions: read-all
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
cancel-in-progress: true
jobs:
terraform-check:
name: IaC Check (${{ matrix.label }})
runs-on: ubuntu-latest
permissions:
contents: read # for actions/checkout to fetch code
issues: write # for create or update comment
pull-requests: write # for create or update comment
strategy:
fail-fast: false
matrix:
include:
- engine: terraform
cli: terraform
version: "~1.9.0"
label: "Terraform ~1.9.0"
- engine: terraform
cli: terraform
version: "~1.10.0"
label: "Terraform ~1.10.0"
- engine: terraform
cli: terraform
version: "~1.11.0"
label: "Terraform ~1.11.0"
- engine: terraform
cli: terraform
version: "~1.12.0"
label: "Terraform ~1.12.0"
- engine: terraform
cli: terraform
version: "~1.13.0"
label: "Terraform ~1.13.0"
- engine: terraform
cli: terraform
version: "~1.14.0"
label: "Terraform ~1.14.0"
- engine: tofu
cli: tofu
version: "~1.11.0"
label: "OpenTofu ~1.11.0"
- engine: tofu
cli: tofu
version: "~1.10.0"
label: "OpenTofu ~1.10.0"
- engine: tofu
cli: tofu
version: "~1.9.0"
label: "OpenTofu ~1.9.0"
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
- name: Configure IaC plugin cache
run: |
echo 'plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"' > ~/.terraformrc
mkdir -p ~/.terraform.d/plugin-cache
- name: Cache IaC
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ~/.terraform.d/plugin-cache
key: "${{ runner.os }}-${{ matrix.engine }}-${{ matrix.version }}-${{ hashFiles('.terraform.lock.hcl') }}"
restore-keys: "${{ runner.os }}-${{ matrix.engine }}-"
- name: Setup Terraform
if: matrix.engine == 'terraform'
uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4.0.0
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
terraform_version: ${{ matrix.version }}
- name: Setup OpenTofu
if: matrix.engine == 'tofu'
uses: opentofu/setup-opentofu@fc711fa910b93cba0f3fbecaafc9f42fd0c411cb # v2.0.0
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
tofu_version: ${{ matrix.version }}
- name: Save terraform version to output
if: matrix.engine == 'terraform'
id: terraform-version
run: |
terraform version
echo "TERRAFORM_VERSION=$(terraform version --json | jq -r '.terraform_version')" >> $GITHUB_OUTPUT
- name: IaC Format
id: fmt
run: ${{ matrix.cli }} fmt -recursive -check -diff
continue-on-error: true
- name: IaC Init
id: init
run: ${{ matrix.cli }} init -no-color
continue-on-error: true
- name: IaC Validate
id: validate
run: ${{ matrix.cli }} validate -no-color
continue-on-error: true
- name: Find Comment
if: matrix.engine == 'terraform' && github.event_name == 'pull_request_target'
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: |
Terraform-Check (version: ${{ steps.terraform-version.outputs.TERRAFORM_VERSION }})
- name: Create or update comment
if: matrix.engine == 'terraform' && github.event_name == 'pull_request_target'
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
### Terraform-Check (version: ${{ steps.terraform-version.outputs.TERRAFORM_VERSION }}): ${{ steps.fmt.outcome == 'success' && steps.init.outcome == 'success' && steps.validate.outcome == 'success' && '✅' || '❌' }}
<details><summary>🖌 Terraform Format: ${{ steps.fmt.outcome == 'success' && '✅' || '❌' }}</summary>
```
# Outputs:
${{ steps.fmt.outputs.stdout }}
# Errors:
${{ steps.fmt.outputs.stderr }}
```
</details>
<details><summary>⚙️ Terraform Init: ${{ steps.init.outcome == 'success' && '✅' || '❌' }}</summary>
```
# Outputs:
${{ steps.init.outputs.stdout }}
# Errors:
${{ steps.init.outputs.stderr }}
```
</details>
<details><summary>🤖 Terraform Validate: ${{ steps.validate.outcome == 'success' && '✅' || '❌' }}</summary>
```
# Outputs:
${{ steps.validate.outputs.stdout }}
# Errors:
${{ steps.validate.outputs.stderr }}
```
</details>
- name: Fail on error
if: ${{
steps.fmt.outcome != 'success'
|| steps.init.outcome != 'success'
|| steps.validate.outcome != 'success'
}}
run: |
exit 1
commitlint:
name: Commitlint
runs-on: ubuntu-latest
permissions:
contents: read # for actions/checkout to fetch code
issues: write # for create or update comment
pull-requests: write # for create or update comment
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
- name: Setup Node and Yarn Cache
uses: ./.github/actions/setup-node-and-yarn-cache
with:
cache-dependency-path: .github.qkg1.topmitlint/yarn.lock
- name: Yarn install
run: yarn install --immutable --immutable-cache
working-directory: ./.github.qkg1.topmitlint
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: yarn commitlint --last --verbose
working-directory: ./.github.qkg1.topmitlint
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request_target'
id: validate
run: |
yarn commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose > commitlint_output.txt
working-directory: ./.github.qkg1.topmitlint
- name: Print commitlint output
if: ${{ always() && github.event_name == 'pull_request_target' }}
run: |
echo $(cat ./.github.qkg1.topmitlint/commitlint_output.txt)
- name: Set commitlint output to env
if: ${{ always() && github.event_name == 'pull_request_target' }}
run: |
{
echo 'commitlint_output<<EOF'
cat ./.github.qkg1.topmitlint/commitlint_output.txt
echo EOF
} >> "$GITHUB_ENV"
- name: Find Comment
if: ${{ always() && github.event_name == 'pull_request_target' }}
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: |
Commitlint-Check
- name: Create or update commitlint comment on failure
if: ${{ failure() && github.event_name == 'pull_request_target' }}
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
### Commitlint-Check
Thanks for your contribution :heart:
Unfortunately, [commitlint](https://commitlint.js.org) has detected that this PR has one ore more commit messages that do not follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/) :scream_cat:
```
${{ env.commitlint_output }}
```
Please update the commit messages accordingly.
reactions: eyes
- name: Create or update commitlint comment on success
if: ${{ success() && github.event_name == 'pull_request_target' }}
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
### Commitlint-Check
Thanks for your contribution :heart:
[commitlint](https://commitlint.js.org) has detected that all commit messages in this PR follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/) :tada:
reactions: hooray
dev_xperience_status_check:
name: DevXperience status check
if: ${{ always() && !cancelled() }}
runs-on: ubuntu-latest
needs:
- terraform-check
- commitlint
steps:
- name: Fail on error
# see https://stackoverflow.com/a/67532120/4907315 and https://github.com/orgs/community/discussions/26822#discussioncomment-3305794
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}
run: |
echo There are failing or cancelled jobs
exit 1