Skip to content

Commit 18a4ad4

Browse files
authored
Merge pull request #65 from turkenf/update-ci
Enable pushing xpkg.upbound.io in CI
2 parents f2099c2 + 944cd89 commit 18a4ad4

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ env:
2323
XP_CHANNEL: stable
2424
XP_VERSION: v1.20.0
2525

26+
# This CI job will automatically push new builds to xpkg.upbound.io if the
27+
# XPKG_ACCESS_ID and XPKG_TOKEN secrets are set in the GitHub respository (or
28+
# organization) settings. Create a token at https://accounts.upbound.io.
29+
XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }}
30+
2631
# The package to push, without a version tag. The default matches GitHub. For
27-
# example xpkg.crossplane.io/crossplane/function-template-go. Note that
28-
# xpkg.crossplane.io is just an alias for ghcr.io, so we upload to ghcr.io but
29-
# this'll be pulled from xpkg.crossplane.io.
30-
XPKG: ghcr.io/${{ github.repository}}
32+
# example xpkg.upbound.io/crossplane/function-template-go.
33+
XPKG: xpkg.upbound.io/${{ github.repository}}
34+
CROSSPLANE_REGORG: ghcr.io/${{ github.repository}} # xpkg.crossplane.io/crossplane-contrib
3135

3236
# The package version to push. The default is 0.0.0-gitsha.
3337
XPKG_VERSION: ${{ inputs.version }}
@@ -127,9 +131,6 @@ jobs:
127131
# pushes them as a multi-platform package.
128132
push:
129133
runs-on: ubuntu-24.04
130-
permissions:
131-
contents: read
132-
packages: write
133134
needs:
134135
- build
135136
steps:
@@ -147,12 +148,13 @@ jobs:
147148
- name: Setup the Crossplane CLI
148149
run: "curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"
149150

150-
- name: Login to GitHub Container Registry
151+
- name: Login to Upbound
151152
uses: docker/login-action@v3
153+
if: env.XPKG_ACCESS_ID != ''
152154
with:
153-
registry: ghcr.io
154-
username: ${{ github.repository_owner }}
155-
password: ${{ secrets.GITHUB_TOKEN }}
155+
registry: xpkg.upbound.io
156+
username: ${{ secrets.XPKG_ACCESS_ID }}
157+
password: ${{ secrets.XPKG_TOKEN }}
156158

157159
# If a version wasn't explicitly passed as a workflow_dispatch input we
158160
# default to version v0.0.0-<git-commit-date>-<git-short-sha>, for example
@@ -162,7 +164,16 @@ jobs:
162164
if: env.XPKG_VERSION == ''
163165
run: echo "XPKG_VERSION=v0.0.0-$(date -d@$(git show -s --format=%ct) +%Y%m%d%H%M%S)-$(git rev-parse --short=12 HEAD)" >> $GITHUB_ENV
164166

165-
- name: Push Multi-Platform Package to GitHub Container Registry
166-
# XPKG repo name can't contain uppercase characters like UpboundCare, we need to lowercase if the GithubOrg contains them.
167-
# See https://github.com/orgs/community/discussions/25768#discussioncomment-8057564 for XPKG@L lowercase explanation
168-
run: "./crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${XPKG@L}:${{ env.XPKG_VERSION }}"
167+
- name: Push Multi-Platform Package to Upbound
168+
if: env.XPKG_ACCESS_ID != ''
169+
run: "./crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${{ env.XPKG }}:${{ env.XPKG_VERSION }}"
170+
171+
- name: Login to GHCR
172+
uses: docker/[email protected]
173+
with:
174+
registry: ghcr.io
175+
username: ${{ github.repository_owner }}
176+
password: ${{ secrets.GITHUB_TOKEN }}
177+
178+
- name: Push Multi-Platform Package to GHCR
179+
run: "./crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${{ env.CROSSPLANE_REGORG }}:${{ env.XPKG_VERSION }}"

0 commit comments

Comments
 (0)