Skip to content

Commit 5e37987

Browse files
committed
fix: update Kaniko workflow for improved clarity and consistency in naming and structure
1 parent 1f64630 commit 5e37987

File tree

1 file changed

+44
-25
lines changed

1 file changed

+44
-25
lines changed
Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Push Fetch Repos Bot Runner Docker Image with Kaniko
1+
name: Build & Push Fetch-Repos Bot Runner image (Kaniko)
22

33
on:
44
push:
@@ -14,55 +14,74 @@ on:
1414
workflow_dispatch:
1515

1616
env:
17-
IMAGE: ghcr.io/${{ github.repository_owner }}/fetch-repos-bot-runner # base ref
17+
IMAGE_BASE: ghcr.io/${{ github.repository_owner }}/fetch-repos-bot-runner
18+
CACHE_IMG: ghcr.io/${{ github.repository_owner }}/fetch-repos-bot-runner-cache:latest
1819

1920
concurrency:
2021
group: kaniko-${{ github.ref }}
2122
cancel-in-progress: true
2223

2324
jobs:
24-
build-and-push:
25+
build:
2526
runs-on: fetch-repos-bot-runner-k8s-kaniko
26-
# ‼️ Whole job runs inside Kaniko ⇒ secret-file always present
27+
28+
# 👇 whole job runs in Kaniko → Node is gone, but git is present
2729
container:
2830
image: gcr.io/kaniko-project/executor:v1.23.2-debug
2931

3032
permissions:
31-
contents: read # checkout
32-
packages: write # push to GHCR
33+
contents: read
34+
packages: write # push to GHCR
3335

3436
steps:
35-
- name: Checkout repository
36-
uses: actions/checkout@v4
37-
38-
- name: Copy config files (robot, conda)
37+
# ------------------------------------------------------------------
38+
# 1 Clone the repository with plain git (no Node, no checkout action)
39+
# ------------------------------------------------------------------
40+
- name: Clone repository
41+
env:
42+
PAT: ${{ secrets.GHCR_PAT }} # PAT with write:packages (+repo if private)
3943
run: |
40-
cp robot.yaml repos/fetch-repos/
41-
cp conda.yaml repos/fetch-repos/
44+
git config --global url."https://${{ github.actor }}:${PAT}@github.com/".insteadOf "https://github.com/"
45+
git clone --depth 1 \
46+
--branch "${GITHUB_REF##*/}" \
47+
"https://github.com/${{ github.repository }}" repo
48+
49+
# copy extra files into build context
50+
cp robot.yaml repo/repos/fetch-repos/
51+
cp conda.yaml repo/repos/fetch-repos/
4252
43-
- name: Write GHCR auth file
53+
# ------------------------------------------------------------------
54+
# 2 Write GHCR auth file for Kaniko
55+
# ------------------------------------------------------------------
56+
- name: Write /kaniko/.docker/config.json
4457
env:
45-
GHCR_PAT: ${{ secrets.CR_PAT }} # PAT with write:packages (+repo if private)
58+
PAT: ${{ secrets.GHCR_PAT }}
4659
run: |
4760
mkdir -p /kaniko/.docker
48-
echo '{"auths":{"ghcr.io":{"auth":"'"$(echo -n "${{ github.actor }}:${GHCR_PAT}" | base64 -w0)"'"}}}' \
61+
echo '{"auths":{"ghcr.io":{"auth":"'"$(echo -n '${{ github.actor }}:${PAT}' | base64 -w0)"'"}}}' \
4962
> /kaniko/.docker/config.json
5063
51-
- name: Build & push SHA tag
64+
# ------------------------------------------------------------------
65+
# 3 Build & push commit-SHA tag
66+
# ------------------------------------------------------------------
67+
- name: Build + push ${IMAGE_BASE}:${{ github.sha }}
5268
run: |
5369
/kaniko/executor \
54-
--dockerfile=repos/fetch-repos/Dockerfile \
55-
--context=./repos/fetch-repos \
56-
--destination=${{ env.IMAGE }}:${{ github.sha }} \
70+
--dockerfile=repo/repos/fetch-repos/Dockerfile \
71+
--context=repo/repos/fetch-repos \
72+
--destination=${IMAGE_BASE}:${GITHUB_SHA} \
5773
--cache=true \
58-
--cache-repo=${{ env.IMAGE }}-cache:latest
74+
--cache-repo=${CACHE_IMG}
5975
60-
- name: Build & push latest (main branch only)
76+
# ------------------------------------------------------------------
77+
# 4 Tag :latest on main
78+
# ------------------------------------------------------------------
79+
- name: Build + push :latest
6180
if: github.ref == 'refs/heads/main'
6281
run: |
6382
/kaniko/executor \
64-
--dockerfile=repos/fetch-repos/Dockerfile \
65-
--context=./repos/fetch-repos \
66-
--destination=${{ env.IMAGE }}:latest \
83+
--dockerfile=repo/repos/fetch-repos/Dockerfile \
84+
--context=repo/repos/fetch-repos \
85+
--destination=${IMAGE_BASE}:latest \
6786
--cache=true \
68-
--cache-repo=${{ env.IMAGE }}-cache:latest
87+
--cache-repo=${CACHE_IMG}

0 commit comments

Comments
 (0)