Skip to content

Commit 5ed2c0d

Browse files
authored
Merge pull request #52 from maia-iyer/create_ghcr_action
Create ghcr action
2 parents 14f871f + b1ea6d5 commit 5ed2c0d

File tree

3 files changed

+80
-6
lines changed

3 files changed

+80
-6
lines changed

.github/workflows/ghcr-push.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: ghcr.push
2+
# This GitHub action builds an image
3+
4+
run-name: Push image to ghcr
5+
on:
6+
push:
7+
branches:
8+
- '*'
9+
jobs:
10+
build-and-push-image:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: '0'
20+
- name: Log in to GHCR.io
21+
uses: docker/[email protected]
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.repository_owner }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
- name: Get image tag
27+
run: echo "GITHUB_SHA=$GITHUB_SHA" > .env.local
28+
- name: Set release repo
29+
run: echo "IMAGE_REPOSITORY=ghcr.io/${{ github.repository_owner }}/mcad-dashboard:$GITHUB_SHA" >> .env.local
30+
- name: Set container builder
31+
run: echo "CONTAINER_BUILDER=docker" >> .env.local
32+
- name: Build image
33+
run: make build
34+
- name: Push image
35+
run: make push
36+
- name: Print job result
37+
run: |
38+
cat <<EOF >>"${GITHUB_STEP_SUMMARY}"
39+
- This job's stats is ${{ job.status }}.
40+
EOF
41+
tag-version-on-main:
42+
runs-on: ubuntu-latest
43+
needs: build-and-push-image
44+
if: github.ref == 'refs/heads/main'
45+
permissions:
46+
contents: read
47+
packages: write
48+
steps:
49+
- name: Git checkout
50+
uses: actions/checkout@v3
51+
with:
52+
fetch-depth: '0'
53+
- name: Log in to GHCR.io
54+
uses: docker/[email protected]
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.repository_owner }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
- name: Get image tag
60+
run: echo "GITHUB_SHA=$GITHUB_SHA" >> $GITHUB_OUTPUT
61+
- name: Set origin image tag
62+
id: origin
63+
run: echo "IMAGE_REPOSITORY=ghcr.io/${{ github.repository_owner }}/mcad-dashboard:$GITHUB_SHA" >> $GITHUB_OUTPUT
64+
- name: Set version image tag # TODO make version dynamic
65+
id: target
66+
run: echo "VERSION_TAG=ghcr.io/${{ github.repository_owner }}/mcad-dashboard:v0.1.0" >> $GITHUB_OUTPUT
67+
- name: Tag and push image
68+
env:
69+
ORIGIN_REPO: ${{ steps.origin.outputs.IMAGE_REPOSITORY }}
70+
TARGET_REPO: ${{ steps.target.outputs.VERSION_TAG }}
71+
run: |
72+
docker pull ${{ env.ORIGIN_REPO }}
73+
docker tag ${{ env.ORIGIN_REPO }} ${{ env.TARGET_REPO }}
74+
docker push ${{ env.TARGET_REPO }}

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ WORKDIR /usr/src/app/backend
4545

4646
CMD ["npm", "run", "start"]
4747

48-
LABEL io.opendatahub.component="odh-dashboard" \
49-
io.k8s.display-name="odh-dashboard" \
50-
name="open-data-hub/odh-dashboard-ubi8" \
51-
summary="odh-dashboard" \
52-
description="Open Data Hub Dashboard"
48+
LABEL io.opendatahub.component="mcad-dashboard" \
49+
io.k8s.display-name="mcad-dashboard" \
50+
name="project-codeflare/mcad-dashboard-ubi8" \
51+
summary="mcad-dashboard" \
52+
description="MCAD Dashboard"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include ${ENV_FILE}
1010
export $(shell sed 's/=.*//' ${ENV_FILE})
1111
endif
1212

13-
CONTAINER_BUILDER=podman
13+
CONTAINER_BUILDER ?= podman
1414
CONTAINER_DOCKERFILE=Dockerfile
1515
EXPORTER_DOCKERFILE=Dockerfile.exporter
1616

0 commit comments

Comments
 (0)