Skip to content

Commit dd4e73d

Browse files
🎨 Update workflows (#128)
Co-authored-by: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com>
1 parent 25e6e28 commit dd4e73d

File tree

9 files changed

+193
-70
lines changed

9 files changed

+193
-70
lines changed

.github/workflows/pull-request.yml renamed to .github/workflows/auto-create-pull-request.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pull Request
1+
name: (Auto) Create Pull Request
22

33
on:
44
push:
@@ -31,7 +31,7 @@ jobs:
3131
run: task lint
3232

3333
build-and-push:
34-
name: Build and Push test
34+
name: Build and push
3535
runs-on: ubuntu-24.04-arm
3636
needs: [lint]
3737
steps:
@@ -85,7 +85,6 @@ jobs:
8585
version: 3.x
8686

8787
- name: Get template
88-
shell: bash
8988
run: task git:get-pr-template
9089

9190
- name: Create Pull Request

.github/workflows/release.yml renamed to .github/workflows/auto-create-release.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
name: Manual Release
1+
name: (Auto) Create release
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
version:
7-
description: Release version (e.g., v1.2.3)
8-
required: true
9-
type: string
10-
default: __TAKEN_FROM_ACTION_YML__
4+
pull_request:
5+
types: [closed]
6+
push:
7+
branches:
8+
- release/**
119

1210
permissions:
1311
contents: write
1412
packages: write
1513

1614
jobs:
1715
release:
16+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
1817
name: Create Release
1918
runs-on: ubuntu-24.04-arm
2019
steps:
@@ -32,9 +31,9 @@ jobs:
3231
- name: Create and push git tags
3332
id: version
3433
env:
35-
VERSION_OVERRIDE: ${{ github.event.inputs.version }}
3634
VERSION_SUFFIX: ""
3735
run: |
36+
task lint
3837
task git:set-config
3938
task version:tag-release
4039
echo "REL_VERSION=$(task version:get)" >> "$GITHUB_OUTPUT"
@@ -52,25 +51,22 @@ jobs:
5251

5352
- name: Get Docker commands
5453
env:
55-
VERSION_OVERRIDE: ${{ github.event.inputs.version }}
5654
VERSION_SUFFIX: ""
5755
run: task docker:cmds
5856

59-
- name: Build and push Docker images
57+
- name: Build and Push
6058
env:
6159
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
6260
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
VERSION_OVERRIDE: ${{ github.event.inputs.version }}
6461
VERSION_SUFFIX: ""
6562
run: task docker:push
6663

6764
- name: Inspect image
6865
env:
69-
VERSION_OVERRIDE: ${{ github.event.inputs.version }}
7066
VERSION_SUFFIX: ""
7167
run: task docker:push:inspect
7268

73-
- name: Create GitHub Release
69+
- name: Create GitHub release
7470
uses: softprops/action-gh-release@v2
7571
with:
7672
tag_name: ${{ steps.version.outputs.REL_VERSION }}
@@ -81,7 +77,7 @@ jobs:
8177
env:
8278
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8379

84-
- name: Update Docker Hub description
80+
- name: Update Docker hub description
8581
uses: peter-evans/dockerhub-description@v5
8682
with:
8783
username: ${{ vars.DOCKER_USERNAME }}

.github/workflows/weekly-dependency-check.yml renamed to .github/workflows/cron-check-dependencies.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Weekly Dependency Check
1+
name: (Cron) Check dependencies
22

33
on:
44
schedule:
@@ -11,7 +11,7 @@ permissions:
1111

1212
jobs:
1313
dependency-check:
14-
name: Test Dependencies
14+
name: Test dependencies
1515
runs-on: ubuntu-24.04-arm
1616
steps:
1717
- name: Checkout
@@ -36,6 +36,9 @@ jobs:
3636
image: tonistiigi/binfmt:latest
3737
platforms: amd64,arm64
3838

39+
- name: Run linters
40+
run: task lint
41+
3942
- name: Get Docker commands
4043
run: task docker:cmds
4144

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: (Manual) Update Version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
type:
7+
description: Bump type
8+
required: true
9+
default: patch
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
- set
16+
version:
17+
description: Explicit version when type="set" (e.g., v1.2.3)
18+
required: false
19+
default: ''
20+
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
packages: write
25+
26+
jobs:
27+
update:
28+
name: Update version and push release branch
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v5
33+
with:
34+
fetch-depth: 0
35+
fetch-tags: true
36+
37+
- name: Install Task
38+
uses: arduino/setup-task@v2.0.0
39+
with:
40+
version: 3.x
41+
42+
- name: Update version
43+
id: version
44+
env:
45+
BUMP_TYPE: ${{ github.event.inputs.type }}
46+
INPUT_VERSION: ${{ github.event.inputs.version }}
47+
run: |
48+
set -eux
49+
case "${BUMP_TYPE}" in
50+
set)
51+
if [ -z "${INPUT_VERSION}" ]; then
52+
echo "Missing version for type=set"
53+
exit 1
54+
fi
55+
task version:set VERSION_OVERRIDE="${INPUT_VERSION}"
56+
;;
57+
patch)
58+
task version:update:patch
59+
;;
60+
minor)
61+
task version:update:minor
62+
;;
63+
major)
64+
task version:update:major
65+
;;
66+
*)
67+
echo "Unknown type: ${BUMP_TYPE}"
68+
exit 1
69+
;;
70+
esac
71+
echo "REL_VERSION=$(task version:get)" >> "$GITHUB_OUTPUT"
72+
73+
- name: Install Docker Buildx
74+
uses: docker/setup-buildx-action@v3
75+
with:
76+
install: true
77+
78+
- name: Install QEMU
79+
uses: docker/setup-qemu-action@v3
80+
with:
81+
image: tonistiigi/binfmt:latest
82+
platforms: amd64,arm64
83+
84+
- name: Get Docker commands
85+
run: task docker:cmds
86+
87+
- name: Build and push test image
88+
env:
89+
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
run: task docker:push
92+
93+
- name: Inspect image
94+
run: task docker:push:inspect
95+
96+
- name: Get template
97+
env:
98+
VERSION_SUFFIX: ""
99+
run: |
100+
task git:set-config
101+
task git:get-pr-template
102+
103+
- name: Push to release branch
104+
uses: devops-infra/action-commit-push@v1
105+
with:
106+
github_token: ${{ secrets.GITHUB_TOKEN }}
107+
commit_message: ":rocket: Bump version to ${{ steps.version.outputs.REL_VERSION }}"
108+
target_branch: ${{ format('release/{0}', steps.version.outputs.REL_VERSION) }}
109+
110+
- name: Create Pull Request
111+
uses: devops-infra/action-pull-request@v1
112+
with:
113+
github_token: ${{ secrets.GITHUB_TOKEN }}
114+
assignee: ${{ github.actor }}
115+
template: .tmp/PULL_REQUEST_TEMPLATE.md
116+
get_diff: true

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ FROM devopsinfra/docker-terragrunt:slim-latest AS builder
44
# Use a clean tiny image to store artifacts in
55
FROM ubuntu:questing-20251007
66

7+
# Disable interactive mode
8+
ENV DEBIAN_FRONTEND=noninteractive
9+
710
# Copy all needed files
811
COPY --from=builder /usr/bin/terraform /usr/bin/format-hcl /usr/bin/fmt.sh /usr/bin/terragrunt-fmt.sh /usr/bin/
912
COPY entrypoint.sh /

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2021 Krzysztof Szyper aka ChristophShyper (https://shyper.pro/)
3+
Copyright (c) 2020 Krzysztof Szyper aka ChristophShyper (https://shyper.pro/)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# GitHub Action for formating HCL files
2-
32
**GitHub Action automatically formatting all [HCL](https://github.com/hashicorp/hcl) and [TF](https://www.terraform.io/docs/configuration/index.html) files (.hcl, .tf, .tfvars).**
43

54

65
## 📦 Available on
7-
86
- **Docker Hub:** [devopsinfra/action-format-hcl:latest](https://hub.docker.com/repository/docker/devopsinfra/action-format-hcl)
97
- **GitHub Packages:** [ghcr.io/devops-infra/action-format-hcl:latest](https://github.com/devops-infra/action-format-hcl/pkgs/container/action-format-hcl)
108

119

1210
## ✨ Features
13-
1411
* Container is a stripped down image of my other creation - [devopsinfra/docker-terragrunt](https://github.com/devopsinfra/docker-terragrunt) - framework for managing Infrastructure-as-a-Code.
1512
* Main use will be everywhere where [Terraform](https://github.com/hashicorp/terraform) or [Terragrunt](https://github.com/gruntwork-io/terragrunt) is used.
1613
* Using combination of my wrapper for [cytopia](https://github.com/cytopia)'s [docker-terragrunt-fmt](https://github.com/cytopia/docker-terragrunt-fmt).
1714

1815

19-
## 📊 Badges
16+
## 🔗 Related Actions
17+
**Useful in combination with my other action [devops-infra/action-commit-push](https://github.com/devops-infra/action-commit-push).**
18+
2019

20+
## 📊 Badges
2121
[
2222
![GitHub repo](https://img.shields.io/badge/GitHub-devops--infra%2Faction--format--hcl-blueviolet.svg?style=plastic&logo=github)
2323
![GitHub last commit](https://img.shields.io/github/last-commit/devops-infra/action-format-hcl?color=blueviolet&logo=github&style=plastic&label=Last%20commit)
@@ -33,8 +33,14 @@
3333
](https://hub.docker.com/r/devopsinfra/action-format-hcl "shields.io")
3434

3535

36-
## 📖 API Reference
36+
## 🏷️ Version Tags: vX, vX.Y, vX.Y.Z
37+
This action supports three tag levels for flexible versioning:
38+
- `vX`: latest patch of the major version (e.g., `v1`).
39+
- `vX.Y`: latest patch of the minor version (e.g., `v1.2`).
40+
- `vX.Y.Z`: fixed to a specific release (e.g., `v1.2.3`).
41+
3742

43+
## 📖 API Reference
3844
```yaml
3945
- name: Run the Action
4046
uses: devops-infra/action-format-hcl@v1.0.0
@@ -50,7 +56,6 @@
5056
5157
5258
### 🔧 Input Parameters
53-
5459
| Input Variable | Required | Default | Description |
5560
|----------------|----------|---------|---------------------------------------------------------------|
5661
| `list` | No | `false` | List files containing formatting inconsistencies. |
@@ -63,7 +68,6 @@
6368

6469

6570
### 📤 Outputs Parameters
66-
6771
| Output | Description |
6872
|-----------------|-----------------------|
6973
| `files_changed` | List of changed files |
@@ -72,7 +76,6 @@
7276
## 💻 Usage Examples
7377

7478
### 📝 Basic Example
75-
7679
Action can fail if malformed files will be found.
7780

7881
```yaml
@@ -93,7 +96,6 @@ jobs:
9396
```
9497

9598
### 🔀 Advanced Example
96-
9799
Action can automatically format all HCL files and commit updated files back to the repository using my other action [action-commit-push](https://github.com/devops-infra/action-commit-push).
98100

99101
```yaml
@@ -118,24 +120,16 @@ jobs:
118120
```
119121

120122

121-
## 🔗 Related Actions
122-
123-
- [devops-infra/action-commit-push](https://github.com/devops-infra/action-commit-push) - Commit and push changes to a git repository
124-
125-
126123
## 🤝 Contributing
127-
128124
Contributions are welcome! See [CONTRIBUTING](https://github.com/devops-infra/.github/blob/master/CONTRIBUTING.md).
129125
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
130126

131127

132128
## 📄 License
133-
134129
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
135130

136131

137132
## 💬 Support
138-
139133
If you have any questions or need help, please:
140134
- 📝 Create an [issue](https://github.com/devops-infra/action-format-hcl/issues)
141135
- 🌟 Star this repository if you find it useful!

Taskfile.scripts.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,21 @@ tasks:
9393
desc: Update version in README.md and action.yml
9494
cmds:
9595
- |
96-
# check if VERSION if different than LAST_RELEASE
97-
if [ "{{.VERSION}}" = "{{.LAST_RELEASE}}" ]; then
98-
echo "❌ ERROR: VERSION is same as LAST_RELEASE ({{.VERSION}})"
96+
# check if VERSION if different than VERSION_FROM_ACTION_YML
97+
if [ "{{.VERSION}}" = "{{.VERSION_FROM_ACTION_YML}}" ]; then
98+
echo "❌ ERROR: VERSION is same as VERSION_FROM_ACTION_YML ({{.VERSION}})"
9999
exit 1
100100
fi
101-
- echo Updating full version from {{.LAST_RELEASE}} to {{.VERSION}}
102-
- echo Updating minor version from {{.LAST_MINOR}} to {{.VERSION_MINOR}}
103-
- echo Updating major version from {{.LAST_MAJOR}} to {{.VERSION_MAJOR}}
104-
- "{{.SED}} -i 's#{{.DOCKER_NAME}}:{{.LAST_RELEASE}}#{{.DOCKER_NAME}}:{{.VERSION}}#g' action.yml"
105-
- "{{.SED}} -i 's#{{.DOCKER_NAME}}@{{.LAST_RELEASE}}#{{.DOCKER_NAME}}@{{.VERSION}}#g' README.md"
106-
- "{{.SED}} -i 's#{{.GITHUB_NAME}}@{{.LAST_RELEASE}}#{{.GITHUB_NAME}}@{{.VERSION}}#g' README.md"
107-
- "{{.SED}} -i 's#{{.DOCKER_NAME}}@{{.LAST_MINOR}}#{{.DOCKER_NAME}}@{{.VERSION_MINOR}}#g' README.md"
108-
- "{{.SED}} -i 's#{{.GITHUB_NAME}}@{{.LAST_MINOR}}#{{.GITHUB_NAME}}@{{.VERSION_MINOR}}#g' README.md"
109-
- "{{.SED}} -i 's#{{.DOCKER_NAME}}@{{.LAST_MAJOR}}#{{.DOCKER_NAME}}@{{.VERSION_MAJOR}}#g' README.md"
110-
- "{{.SED}} -i 's#{{.GITHUB_NAME}}@{{.LAST_MAJOR}}#{{.GITHUB_NAME}}@{{.VERSION_MAJOR}}#g' README.md"
101+
- echo Updating full version from {{.VERSION_FROM_ACTION_YML}} to {{.VERSION}}
102+
- echo Updating minor version from {{.MINOR_FROM_ACTION_YML}} to {{.VERSION_MINOR}}
103+
- echo Updating major version from {{.MAJOR_FROM_ACTION_YML}} to {{.VERSION_MAJOR}}
104+
- "{{.SED}} -i 's#{{.DOCKER_NAME}}:{{.VERSION_FROM_ACTION_YML}}#{{.DOCKER_NAME}}:{{.VERSION}}#g' action.yml"
105+
- "{{.SED}} -i 's#{{.DOCKER_NAME}}@{{.VERSION_FROM_ACTION_YML}}#{{.DOCKER_NAME}}@{{.VERSION}}#g' README.md"
106+
- "{{.SED}} -i 's#{{.GITHUB_NAME}}@{{.VERSION_FROM_ACTION_YML}}#{{.GITHUB_NAME}}@{{.VERSION}}#g' README.md"
107+
- "{{.SED}} -i 's#{{.DOCKER_NAME}}@{{.MINOR_FROM_ACTION_YML}}#{{.DOCKER_NAME}}@{{.VERSION_MINOR}}#g' README.md"
108+
- "{{.SED}} -i 's#{{.GITHUB_NAME}}@{{.MINOR_FROM_ACTION_YML}}#{{.GITHUB_NAME}}@{{.VERSION_MINOR}}#g' README.md"
109+
- "{{.SED}} -i 's#{{.DOCKER_NAME}}@{{.MAJOR_FROM_ACTION_YML}}#{{.DOCKER_NAME}}@{{.VERSION_MAJOR}}#g' README.md"
110+
- "{{.SED}} -i 's#{{.GITHUB_NAME}}@{{.MAJOR_FROM_ACTION_YML}}#{{.GITHUB_NAME}}@{{.VERSION_MAJOR}}#g' README.md"
111111

112112
lint:actionlint:
113113
desc: Lint GitHub Actions workflows with actionlint

0 commit comments

Comments
 (0)