Skip to content

Commit dd5b673

Browse files
authored
Merge pull request #181 from rancher/fix-ci-ratelimit
Add dockerhub login to prevent ratelimit of CI
2 parents 64b2a02 + 2fb4e74 commit dd5b673

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,43 @@ concurrency:
2626
group: ${{ github.workflow }}-${{ github.ref }}
2727
cancel-in-progress: true
2828

29-
permissions:
30-
contents: write # Upload artefacts to release.
31-
3229
env:
3330
PUBLIC_REGISTRY: ghcr.io
3431

3532
jobs:
3633
ci:
34+
permissions:
35+
contents: write # Upload artefacts to release.
36+
# write is needed for:
37+
# - OIDC for cosign's use in ecm-distro-tools/publish-image.
38+
# - Read vault secrets in rancher-eio/read-vault-secrets.
39+
id-token: write
40+
packages: write
41+
attestations: write
3742
runs-on: runs-on,runner=2cpu-linux-x64,run-id=${{ github.run_id }}
3843
steps:
44+
- name: Check out repository code
45+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
46+
47+
- name: Load Secrets from Vault
48+
uses: rancher-eio/read-vault-secrets@main
49+
with:
50+
secrets: |
51+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
52+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD ;
53+
54+
- name: Log in to Docker Hub
55+
uses: docker/login-action@v3
56+
with:
57+
username: ${{ env.DOCKER_USERNAME || vars.DOCKER_USERNAME || github.repository_owner }}
58+
password: ${{ env.DOCKER_PASSWORD || secrets.DOCKER_PASSWORD }}
59+
3960
-
4061
# Add support for more platforms with QEMU (optional)
4162
# https://github.com/docker/setup-qemu-action
4263
name: Set up QEMU
4364
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
44-
- name: Check out repository code
45-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
65+
4666
- name: Basic CI
4767
run: make ci
4868
- name: Upload CI files to artifacts (on failure)

.github/workflows/e2e-ci.yaml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,46 @@ env:
4343
DEBUG: ${{ github.event.inputs.debug || false }}
4444
CLUSTER_NAME: 'e2e-ci-kuberlr-kubectl'
4545

46-
permissions:
47-
contents: write
48-
4946
jobs:
5047
e2e-kuberlr-kubectl:
48+
permissions:
49+
contents: write # Upload artefacts to release.
50+
# write is needed for:
51+
# - OIDC for cosign's use in ecm-distro-tools/publish-image.
52+
# - Read vault secrets in rancher-eio/read-vault-secrets.
53+
id-token: write
54+
packages: write
55+
attestations: write
5156
strategy:
5257
matrix:
5358
arch:
5459
- x64
5560
- arm64
5661
runs-on: ${{ github.repository == 'rancher/kuberlr-kubectl' && format('runs-on,image=ubuntu22-full-{1},runner=4cpu-linux-{1},run-id={0}', github.run_id, matrix.arch) || 'ubuntu-latest' }}
5762
steps:
63+
-
64+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
65+
with:
66+
fetch-depth: 0
67+
68+
- name: Load Secrets from Vault
69+
uses: rancher-eio/read-vault-secrets@main
70+
with:
71+
secrets: |
72+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
73+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD ;
74+
- name: Log in to Docker Hub
75+
uses: docker/login-action@v3
76+
with:
77+
username: ${{ env.DOCKER_USERNAME || vars.DOCKER_USERNAME || github.repository_owner }}
78+
password: ${{ env.DOCKER_PASSWORD || secrets.DOCKER_PASSWORD }}
79+
5880
-
5981
# Add support for more platforms with QEMU (optional)
6082
# https://github.com/docker/setup-qemu-action
6183
name: Set up QEMU
6284
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
63-
-
64-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
65-
with:
66-
fetch-depth: 0
85+
6786
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
6887
with:
6988
go-version: '>=1.20.0'

0 commit comments

Comments
 (0)