-
-
Notifications
You must be signed in to change notification settings - Fork 174
97 lines (89 loc) · 3.26 KB
/
Copy pathatmos-pro.yaml
File metadata and controls
97 lines (89 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
name: atmos.ci
on: pull_request
env:
GOFUMPT_VERSION: v0.9.1
permissions:
contents: read
id-token: write
jobs:
autofix:
# Skip on fork PRs: GitHub withholds id-token (OIDC) and repo vars/secrets
# from fork-originated pull_request runs, so `atmos pro commit` cannot
# authenticate or push and the job always fails for external contributors.
if: >-
github.actor != 'atmos-pro[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on:
- runs-on=${{github.run_id}}
- runner=terraform
- tag=atmos
- extras=s3-cache
- private=false
container:
image: ghcr.io/cloudposse/atmos:1.215.0
permissions:
contents: read
id-token: write
timeout-minutes: 15
steps:
- uses: runs-on/action@d141ef83eb66d096ce8afc767e09115a65c63b60 # v2.1.2
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
fetch-depth: 0
persist-credentials: false
# Install Go and toolchain dependencies
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- run: go mod tidy
- name: Install Go tools
run: |
go install mvdan.cc/gofumpt@${GOFUMPT_VERSION}
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- name: Install toolchain dependencies
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
atmos toolchain install
atmos toolchain env --format=github
# gofumpt
- name: Get changed Go files
id: changed-files
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
use_rest_api: "false"
files: |
**/*.go
- if: steps.changed-files.outputs.all_changed_files_count != '0'
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
# shellcheck disable=SC2086
gofumpt -l -w $ALL_CHANGED_FILES
# Run pre-commit hooks for whitespace fixes
- name: Install pre-commit
run: |
apt-get update && apt-get install -y --no-install-recommends pre-commit
- name: Run pre-commit whitespace fixes
run: |
# Run only the whitespace-related hooks from pre-commit
pre-commit run trailing-whitespace --all-files || true
pre-commit run end-of-file-fixer --all-files || true
# Generate NOTICE file on all PRs to ensure it stays up-to-date
- name: Generate NOTICE file
run: ./scripts/generate-notice.sh
# Format HCL files in test fixtures and examples
- name: Format HCL
run: |
atmos toolchain exec -- tofu fmt -recursive tests/fixtures/components/terraform
atmos toolchain exec -- tofu fmt -recursive examples/
# Regenerate README.md from README.yaml
- name: Regenerate README
run: atmos docs generate readme
- name: Commit fixes via Atmos Pro
env:
ATMOS_LOGS_LEVEL: debug
ATMOS_PRO_WORKSPACE_ID: ${{ vars.ATMOS_PRO_WORKSPACE_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: atmos pro commit -m "[autocommit] formatting fixes" --all