-
Notifications
You must be signed in to change notification settings - Fork 1
42 lines (40 loc) · 1.46 KB
/
ghcr-push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Push Docker image to GitHub Packages
# This workflow runs when any of the following occur:
# - A push is made to a branch called `main` or `seed`
# - A tag starting with "v" is created
on:
push:
branches:
- main
- seed
tags:
- v*
env:
PROJECT: example-project
jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and push everything
run: |
cd csp1_producer
for DIR in strimzi_connect csp2_transformer csp1_producer csp1_consumer csp1_transformer csp2_producer dashboard ;do
IMAGE_NAME=$PROJECT/$DIR
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo "Building $IMAGE_NAME:$VERSION"
echo VERSION=$VERSION
cd ../$DIR
docker build . --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
echo "Pushing $IMAGE_ID:$VERSION"
docker push $IMAGE_ID:$VERSION
done