Skip to content

Commit c8c0009

Browse files
ci: add build and push image workflow
1 parent 62ce03a commit c8c0009

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build and push image
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build-and-push-image:
9+
runs-on: ubuntu-latest
10+
env:
11+
IMAGE_NAME: "oc4ids-datastore-api"
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Login to GitHub Container Registry
15+
uses: docker/login-action@v3
16+
with:
17+
registry: ghcr.io
18+
username: ${{ github.actor }}
19+
password: ${{ secrets.GITHUB_TOKEN }}
20+
- name: Extract version
21+
run: |
22+
TAG=${GITHUB_REF#refs/*/}
23+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
24+
- name: Print version
25+
run: echo $VERSION
26+
- name: Build and push image
27+
run: |
28+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
29+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
30+
echo $IMAGE_ID
31+
docker build . -t ${IMAGE_ID}:${VERSION} -t ${IMAGE_ID}:latest
32+
docker push --all-tags ${IMAGE_ID}

0 commit comments

Comments
 (0)