mirror of
https://github.com/outbackdingo/terraform-hcloud-talos.git
synced 2026-01-27 18:20:26 +00:00
232 lines
8.5 KiB
YAML
232 lines
8.5 KiB
YAML
name: Developer Experience
|
|
on:
|
|
workflow_dispatch:
|
|
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: Terraform Check
|
|
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:
|
|
- version: ~1.8.0
|
|
- version: ~1.9.0
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
|
with:
|
|
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
|
- name: Configure Terraform plugin cache
|
|
run: |
|
|
echo 'plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"' > ~/.terraformrc
|
|
mkdir -p ~/.terraform.d/plugin-cache
|
|
- name: Cache Terraform
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: ~/.terraform.d/plugin-cache
|
|
key: "${{ runner.os }}-terraform-${{ hashFiles(format('{0}/.terraform.lock.hcl', matrix.version)) }}"
|
|
restore-keys: "${{ runner.os }}-terraform-"
|
|
- name: Setup Terraform
|
|
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
|
|
with:
|
|
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
|
|
terraform_version: ${{ matrix.version }}
|
|
- name: Save terraform version to output
|
|
id: terraform-version
|
|
run: |
|
|
terraform version
|
|
echo "TERRAFORM_VERSION=$(terraform version --json | jq -r '.terraform_version')" >> $GITHUB_OUTPUT
|
|
- name: Terraform Format
|
|
id: fmt
|
|
run: terraform fmt -recursive -check -diff
|
|
continue-on-error: true
|
|
- name: Terraform Init
|
|
id: init
|
|
run: terraform init -no-color
|
|
continue-on-error: true
|
|
- name: Terraform Validate
|
|
id: validate
|
|
run: terraform validate -no-color
|
|
continue-on-error: true
|
|
- name: Find Comment
|
|
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
|
|
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@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
|
with:
|
|
fetch-depth: 0
|
|
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
|
- name: Setup Node and Yarn Cache
|
|
uses: ./.github/actions/setup-node-and-yarn-cache
|
|
with:
|
|
cache-dependency-path: .github/commitlint/yarn.lock
|
|
- name: Yarn install
|
|
run: yarn install --immutable --immutable-cache
|
|
working-directory: ./.github/commitlint
|
|
- name: Validate current commit (last commit) with commitlint
|
|
if: github.event_name == 'push'
|
|
run: yarn commitlint --last --verbose
|
|
working-directory: ./.github/commitlint
|
|
- 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/commitlint
|
|
- name: Print commitlint output
|
|
if: ${{ always() }}
|
|
run: |
|
|
echo $(cat ./.github/commitlint/commitlint_output.txt)
|
|
- name: Set commitlint output to env
|
|
if: ${{ always() }}
|
|
run: |
|
|
{
|
|
echo 'commitlint_output<<EOF'
|
|
cat ./.github/commitlint/commitlint_output.txt
|
|
echo EOF
|
|
} >> "$GITHUB_ENV"
|
|
- name: Find Comment
|
|
if: ${{ always() }}
|
|
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() }}
|
|
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() }}
|
|
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
|