|
1 | | -name: Build and Push Fetch Repos Bot Runner Docker Image with Kaniko |
| 1 | +name: Build & Push Fetch-Repos Bot Runner image (Kaniko) |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
14 | 14 | workflow_dispatch: |
15 | 15 |
|
16 | 16 | 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 |
18 | 19 |
|
19 | 20 | concurrency: |
20 | 21 | group: kaniko-${{ github.ref }} |
21 | 22 | cancel-in-progress: true |
22 | 23 |
|
23 | 24 | jobs: |
24 | | - build-and-push: |
| 25 | + build: |
25 | 26 | 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 |
27 | 29 | container: |
28 | 30 | image: gcr.io/kaniko-project/executor:v1.23.2-debug |
29 | 31 |
|
30 | 32 | permissions: |
31 | | - contents: read # checkout |
32 | | - packages: write # push to GHCR |
| 33 | + contents: read |
| 34 | + packages: write # push to GHCR |
33 | 35 |
|
34 | 36 | 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) |
39 | 43 | 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/ |
42 | 52 |
|
43 | | - - name: Write GHCR auth file |
| 53 | + # ------------------------------------------------------------------ |
| 54 | + # 2 Write GHCR auth file for Kaniko |
| 55 | + # ------------------------------------------------------------------ |
| 56 | + - name: Write /kaniko/.docker/config.json |
44 | 57 | env: |
45 | | - GHCR_PAT: ${{ secrets.CR_PAT }} # PAT with write:packages (+repo if private) |
| 58 | + PAT: ${{ secrets.GHCR_PAT }} |
46 | 59 | run: | |
47 | 60 | 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)"'"}}}' \ |
49 | 62 | > /kaniko/.docker/config.json |
50 | 63 |
|
51 | | - - name: Build & push SHA tag |
| 64 | + # ------------------------------------------------------------------ |
| 65 | + # 3 Build & push commit-SHA tag |
| 66 | + # ------------------------------------------------------------------ |
| 67 | + - name: Build + push ${IMAGE_BASE}:${{ github.sha }} |
52 | 68 | run: | |
53 | 69 | /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} \ |
57 | 73 | --cache=true \ |
58 | | - --cache-repo=${{ env.IMAGE }}-cache:latest |
| 74 | + --cache-repo=${CACHE_IMG} |
59 | 75 |
|
60 | | - - name: Build & push latest (main branch only) |
| 76 | + # ------------------------------------------------------------------ |
| 77 | + # 4 Tag :latest on main |
| 78 | + # ------------------------------------------------------------------ |
| 79 | + - name: Build + push :latest |
61 | 80 | if: github.ref == 'refs/heads/main' |
62 | 81 | run: | |
63 | 82 | /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 \ |
67 | 86 | --cache=true \ |
68 | | - --cache-repo=${{ env.IMAGE }}-cache:latest |
| 87 | + --cache-repo=${CACHE_IMG} |
0 commit comments