Skip to content

Merge pull request #17 from Klantinteractie-Servicesysteem/jwt-token-… #70

Merge pull request #17 from Klantinteractie-Servicesysteem/jwt-token-…

Merge pull request #17 from Klantinteractie-Servicesysteem/jwt-token-… #70

Workflow file for this run

name: Docker Image CI
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
env:
IMAGE_NAME: ghcr.io/klantinteractie-servicesysteem/kiss-elastic-sync # lowercase
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build only
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v4
with:
file: src/Kiss.Elastic.Sync/Dockerfile
push: false
load: false
tags: user/app:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Get date
if: github.event_name != 'pull_request'
id: date
run: |
echo "DATE=$(date +'%Y%m%d%H%M%S')-$(echo $GITHUB_SHA | head -c 7)" >> $GITHUB_ENV
- name: Get branch name
if: github.event_name != 'pull_request'
id: branch
run: |
BRANCH_NAME="${{ github.head_ref }}"
if [[ -z "$BRANCH_NAME" ]]; then
BRANCH_NAME="${{ github.ref }}"
BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
fi
BRANCH_NAME=$(echo $BRANCH_NAME | tr / -)
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Set release code
if: github.event_name != 'pull_request'
id: releasecode
run: |
RELEASE=$BRANCH_NAME-$DATE
echo "RELEASE=$RELEASE" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v4
with:
push: true
file: src/Kiss.Elastic.Sync/Dockerfile
tags: ${{env.IMAGE_NAME}}:${{ env.RELEASE }},${{env.IMAGE_NAME}}:latest
cache-from: type=gha
cache-to: type=gha,mode=max