Skip to content

Commit 10c5155

Browse files
authored
push image to staging registry (#159)
* push image to staging registry * add Makefile
1 parent 7a246a5 commit 10c5155

File tree

2 files changed

+51
-21
lines changed

2 files changed

+51
-21
lines changed

.github/workflows/publish-docker-image.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ jobs:
1010
runs-on: ubuntu-latest
1111
permissions:
1212
contents: read
13-
packages: write
13+
id-token: write
1414

1515
steps:
1616
- name: Checkout repository
17-
uses: actions/checkout@v4
18-
- name: Retrieve tag name (tag)
19-
run: |
20-
echo TAG_NAME=$(echo $GITHUB_REF | sed -e "s|refs/tags/||") >> $GITHUB_ENV
21-
- name: Log in to GHCR
22-
uses: docker/login-action@v3
17+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
19+
- name : "Read vault secrets"
20+
uses : rancher-eio/read-vault-secrets@main
2321
with:
24-
registry: ghcr.io
25-
username: ${{ github.actor }}
26-
password: ${{ secrets.GITHUB_TOKEN }}
27-
- name: Set up QEMU
28-
uses: docker/setup-qemu-action@v3
29-
- name: Set up Docker Buildx
30-
uses: docker/setup-buildx-action@v3
31-
- name: Build and push Docker image
32-
uses: docker/build-push-action@v5
22+
secrets: |
23+
secret/data/github/repo/${{ github.repository }}/rancher-prime-stg-registry/credentials registry | STAGING_PRIME_REGISTRY ;
24+
secret/data/github/repo/${{ github.repository }}/rancher-prime-stg-registry/credentials username | STAGING_PRIME_REGISTRY_USERNAME ;
25+
secret/data/github/repo/${{ github.repository }}/rancher-prime-stg-registry/credentials password | STAGING_PRIME_REGISTRY_PASSWORD ;
26+
27+
# This encapsulates: login, qemu, build/push
28+
- name: Build and push image
29+
uses: rancher/ecm-distro-tools/actions/publish-image@master
3330
with:
34-
context: .
35-
platforms: linux/amd64,linux/arm64
36-
push: true
37-
file: package/Dockerfile
38-
tags: ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }}
31+
image: rancher-ai-agent
32+
tag: ${{ github.ref_name }}
33+
push-to-prime: true
34+
push-to-public: false
35+
prime-registry: ${{ env.STAGING_PRIME_REGISTRY }}
36+
prime-repo: rancher
37+
prime-username: ${{ env.STAGING_PRIME_REGISTRY_USERNAME }}
38+
prime-password: ${{ env.STAGING_PRIME_REGISTRY_PASSWORD }}

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Define target platforms, image builder and the fully qualified image name.
2+
TARGET_PLATFORMS ?= linux/amd64,linux/arm64
3+
4+
REPO ?= rancher
5+
DIRTY := $(shell if [ -n "$$(git status --porcelain --untracked-files=no)" ]; then echo "-dirty"; fi)
6+
COMMIT ?= $(shell git rev-parse --short HEAD)
7+
GIT_TAG ?= $(shell git tag -l --contains HEAD | head -n 1)
8+
9+
ifeq ($(DIRTY),)
10+
ifneq ($(GIT_TAG),)
11+
VERSION ?= $(GIT_TAG)
12+
endif
13+
endif
14+
VERSION ?= 0.0.0-$(COMMIT)$(DIRTY)
15+
16+
TAG ?= $(VERSION)
17+
IMAGE = $(REPO)/rancher-ai-agent:$(TAG)
18+
19+
push-image:
20+
docker buildx build \
21+
${IID_FILE_FLAG} \
22+
--build-arg VERSION=$(VERSION) \
23+
--build-arg COMMIT=$(COMMIT) \
24+
--file package/Dockerfile \
25+
--platform=${TARGET_PLATFORMS} \
26+
--sbom=true \
27+
--attest type=provenance,mode=max \
28+
-t ${IMAGE} \
29+
--push \
30+
.

0 commit comments

Comments
 (0)