Skip to content

Commit f1200f4

Browse files
chore: add building catalog GA (#181) (#204)
* chore: add building catalog GA Signed-off-by: Jack Yu <[email protected]> * feat: should include prerelease Signed-off-by: Jack Yu <[email protected]> --------- Signed-off-by: Jack Yu <[email protected]> (cherry picked from commit 1880043) Co-authored-by: Jack Yu <[email protected]>
1 parent 0ca2b05 commit f1200f4

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build Harvester Catalog Image and Publish on Release
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
working-directory: ./
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 1
20+
21+
- name: Run tests
22+
uses: ./.github/actions/lint
23+
24+
build-and-push-extension-catalog:
25+
needs: lint
26+
uses: ./.github/workflows/build-extension-catalog.yml
27+
permissions:
28+
actions: write
29+
contents: read
30+
packages: write
31+
id-token: write
32+
with:
33+
registry_target: docker.io
34+
registry_user: rancher
35+
repository_name: harvester-ui-catalog
36+
secrets: inherit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build and release Extension Catalog Image to registry
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
registry_target:
7+
required: true
8+
type: string
9+
repository_name:
10+
required: true
11+
type: string
12+
registry_user:
13+
required: true
14+
type: string
15+
outputs:
16+
build-extension-catalog-job-status:
17+
value: ${{ jobs.build-extension-catalog.outputs.build-status }}
18+
19+
jobs:
20+
build-and-push-extension-catalog:
21+
name: Build container image
22+
if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
23+
runs-on: ubuntu-latest
24+
permissions:
25+
actions: write
26+
contents: read
27+
packages: write
28+
id-token: write
29+
outputs:
30+
build-status: ${{ job.status }}
31+
steps:
32+
- name: Read Secrets
33+
uses: rancher-eio/read-vault-secrets@main
34+
with:
35+
secrets: |
36+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
37+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD ;
38+
39+
- name: Checkout repository (normal flow)
40+
uses: actions/checkout@v4
41+
42+
- name: Enable Corepack
43+
run: corepack enable
44+
45+
- name: Configure Git
46+
run: |
47+
git config user.name 'github-actions[bot]'
48+
git config user.email 'github-actions[bot]@users.noreply.github.com'
49+
50+
- name: Login to Docker Hub
51+
uses: docker/login-action@v3
52+
with:
53+
username: ${{ env.DOCKER_USERNAME }}
54+
password: ${{ env.DOCKER_PASSWORD }}
55+
56+
- name: Setup Helm
57+
uses: azure/setup-helm@v3
58+
with:
59+
version: v3.8.0
60+
61+
- name: Setup Nodejs with yarn caching
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20'
65+
cache: yarn
66+
67+
- name: Install dependencies
68+
run: yarn
69+
70+
- name: Build and push UI image
71+
run: |
72+
publish="yarn publish-pkgs -c -r ${{ inputs.registry_target }} -o ${{ inputs.registry_user }}"
73+
$publish
74+
75+
REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2)
76+
IMAGE_VERSION=$(cat package.json | jq .version | sed 's/"//g')
77+
FULL_IMAGE_NAME=$(echo ${{ inputs.registry_target }}/${{ inputs.registry_user }}/ui-extension-$REPO_NAME:$IMAGE_VERSION)
78+
IMAGE_ID=$(docker inspect --format='{{.Id}}' $FULL_IMAGE_NAME)
79+
80+
docker tag $IMAGE_ID ${{ inputs.registry_target }}/${{ inputs.registry_user }}/${{ inputs.repository_name }}:$IMAGE_VERSION
81+
docker push ${{ inputs.registry_target }}/${{ inputs.registry_user }}/${{ inputs.repository_name }}:$IMAGE_VERSION

0 commit comments

Comments
 (0)