-
Notifications
You must be signed in to change notification settings - Fork 2
48 lines (43 loc) · 1.44 KB
/
publish-docker-image.yaml
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
43
44
45
46
47
48
name: Publish Docker Image
on:
push:
branches: ["main"]
paths:
- self-registration/**
pull_request:
paths:
- self-registration/**
env:
REGISTRY: quay.io
IMAGE_NAME: nebari/nebari-self-registration
jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: "Checkout Repository 🛎️"
uses: actions/checkout@v3
- name: "Login to Quay Container Registry 🔐"
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: "Set lower case image name"
run: echo "IMAGE_LC=${IMAGE_NAME,,}" >>${GITHUB_ENV}
- name: "Set the timestamp for version"
run: echo "VERSION=$(date +'%Y%m%d-%H%M')" >> ${GITHUB_ENV}
- name: "Build image"
run: docker build self-registration --file self-registration/Dockerfile --tag $IMAGE_LC --label "runnumber=${GITHUB_RUN_ID}"
- name: Push image
run: |
IMAGE_ID=$REGISTRY/$IMAGE_LC
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_LC $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION