Skip to content

Commit 177405e

Browse files
authored
Harden CI workflows
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 226ef2e commit 177405e

6 files changed

Lines changed: 48 additions & 38 deletions

File tree

.github/.kodiak.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ strip_html_comments = true # default: false
1515
always = true # default: false
1616

1717
[approve]
18-
auto_approve_usernames = ["1gtm", "tamalsaha"]
18+
auto_approve_usernames = ["tamalsaha", "1gtm", "1gtm-app[bot]"]

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ jobs:
1919
runs-on: ubuntu-24.04
2020
steps:
2121
- name: Set up Go 1.25
22-
uses: actions/setup-go@v5
22+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
2323
with:
2424
go-version: '1.25'
2525
id: go
2626

2727
- name: Use Node.js 20.x
28-
uses: actions/setup-node@v4
28+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2929
with:
30-
node-version: '20'
30+
node-version: '22'
3131
check-latest: true
3232

3333
- name: Check out code into the Go module directory
34-
uses: actions/checkout@v4
34+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
3535

3636
- name: Prepare git
3737
env:
38-
GITHUB_USER: 1gtm
39-
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
38+
GITHUB_USER: ${{ github.actor }}
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4040
run: |
4141
set -x
4242
git config --global user.name "${GITHUB_USER}"

.github/workflows/release-tracker.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,25 @@ concurrency:
1111

1212
jobs:
1313
build:
14+
if: github.event.pull_request.merged == true
1415
runs-on: ubuntu-24.04
1516

1617
steps:
17-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
1819

19-
- name: Prepare git
20-
env:
21-
GITHUB_USER: 1gtm
22-
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
23-
run: |
24-
git config --global user.name "${GITHUB_USER}"
25-
git config --global user.email "${GITHUB_USER}@appscode.com"
26-
git remote set-url origin https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
27-
28-
- name: Install GitHub CLI
29-
run: |
30-
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
31-
sudo mv bin/hub /usr/local/bin
20+
- name: Generate LGTM App token
21+
id: lgtm-app-token
22+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
23+
with:
24+
client-id: ${{ secrets.LGTM_APP_CLIENT_ID }}
25+
private-key: ${{ secrets.LGTM_APP_PRIVATE_KEY }}
26+
owner: ${{ github.repository_owner }}
27+
repositories: CHANGELOG
28+
permission-pull-requests: write
3229

3330
- name: Update release tracker
34-
if: |
35-
github.event.action == 'closed' &&
36-
github.event.pull_request.merged == true
3731
env:
38-
GITHUB_USER: 1gtm
39-
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
32+
GITHUB_USER: ${{ github.actor }}
33+
GITHUB_TOKEN: ${{ steps.lgtm-app-token.outputs.token }}
4034
run: |
4135
./hack/scripts/update-release-tracker.sh

.github/workflows/release.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,24 @@ jobs:
1414
build:
1515
name: Build
1616
runs-on: firecracker
17+
permissions:
18+
contents: write
19+
packages: write
1720
steps:
18-
- uses: actions/checkout@v1
21+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
22+
with:
23+
fetch-depth: 0
1924

2025
- name: Set up Go 1.25
21-
uses: actions/setup-go@v5
26+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
2227
with:
2328
go-version: '1.25'
2429
id: go
2530

2631
- name: Prepare git
2732
env:
28-
GITHUB_USER: 1gtm
29-
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
33+
GITHUB_USER: ${{ github.actor }}
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3035
run: |
3136
set -x
3237
git config --global user.name "${GITHUB_USER}"
@@ -47,21 +52,32 @@ jobs:
4752
4853
- name: Set up QEMU
4954
id: qemu
50-
uses: docker/setup-qemu-action@v3
55+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
5156
with:
5257
cache-image: false
5358

5459
- name: Set up Docker Buildx
55-
uses: docker/setup-buildx-action@v3
60+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
61+
62+
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
63+
id: app-token
64+
with:
65+
client-id: ${{ secrets.GHCRX_APP_CLIENT_ID }}
66+
private-key: ${{ secrets.GHCRX_APP_PRIVATE_KEY }}
67+
owner: appscode
68+
69+
- name: Login to GitHub Container Registry
70+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
71+
with:
72+
registry: ghcr.io
73+
username: ${{ steps.app-token.outputs.app-slug }}[bot]
74+
password: ${{ steps.app-token.outputs.token }}
5675

5776
- name: Publish to GitHub Container Registry
5877
env:
5978
REGISTRY: ghcr.io/appscode
60-
DOCKER_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
61-
USERNAME: 1gtm
6279
APPSCODE_ENV: prod
6380
run: |
64-
docker login ghcr.io --username ${USERNAME} --password ${DOCKER_TOKEN}
6581
make release COMPRESS=yes
6682
6783
# - name: Publish to Red Hat Ecosystem Catalog
@@ -75,7 +91,7 @@ jobs:
7591
# make docker-certify-redhat
7692

7793
- name: Release
78-
uses: softprops/action-gh-release@v1
94+
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
7995
if: startsWith(github.ref, 'refs/tags/')
8096
with:
8197
files: |

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SRC_REG ?=
2929

3030
# This version-strategy uses git tags to set the version string
3131
git_branch := $(shell git rev-parse --abbrev-ref HEAD)
32-
git_tag := $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")
32+
git_tag := $(shell git describe --tags --exact-match --abbrev=0 2>/dev/null || echo "")
3333
commit_hash := $(shell git rev-parse --verify HEAD)
3434
commit_timestamp := $(shell date --date="@$$(git show -s --format=%ct)" --utc +%FT%T)
3535

hack/scripts/update-release-tracker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ case $GITHUB_BASE_REF in
6969
;;
7070
esac
7171

72-
hub api "$api_url" -f body="$msg"
72+
gh api "$api_url" -f body="$msg"

0 commit comments

Comments
 (0)