Skip to content

Multi coupon support #57

Multi coupon support

Multi coupon support #57

name: Publish Docker Image
on:
push:
branches: ["main"]
paths:
- self-registration/**
pull_request:
paths:
- self-registration/**
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- 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: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login $REGISTRY -u $ --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/$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