summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ghcr-auth.yaml
blob: a51182715b27c8ef565047df83934c85691a1d8f (plain)
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
name: GHCR Authentication test

on:
  pull_request_target:
    branches: ['main']
  push:
    branches: ['main']

permissions:
  contents: read
  packages: read

jobs:
  krane:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v3
        with:
          go-version: 1.19
          check-latest: true

      - name: Install krane
        working-directory: ./cmd/krane
        run: go install .

      - name: Test krane + GHCR
        env:
          GITHUB_TOKEN: ${{ github.token }}
        run: |
          # List the tags
          krane ls ghcr.io/${{ github.repository }}/testimage

      - name: Test krane auth get + GHCR
        env:
          GITHUB_TOKEN: ${{ github.token }}
        shell: bash
        run: |
          CRED1=$(krane auth get ghcr.io)
          CRED2=$(krane auth get ghcr.io)
          if [[ "$CRED1" == "" ]] ; then
            exit 1
          fi
          if [[ "$CRED1" == "$CRED2" ]] ; then
            echo "credentials are cached by infrastructure"
          fi