CI: Update push_image workflow

This commit is contained in:
Maschell 2023-04-10 11:44:43 +02:00
parent 47cf34d090
commit c8a077574e

View File

@ -3,23 +3,41 @@ on:
push: push:
branches: branches:
- main - main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs: jobs:
build: build-and-push-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps: steps:
- uses: actions/checkout@master - name: Checkout repository
- name: Get release version uses: actions/checkout@v3
id: get_release_tag - name: Extract Docker metadata
run: | id: meta
echo RELEASE_VERSION=$(echo $(date '+%Y%m%d')) >> $GITHUB_ENV uses: docker/metadata-action@v4
echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//" | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV with:
echo REPOSITORY_OWNER=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $1}' | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Publish to Registry tags: |
uses: elgohr/Publish-Docker-Github-Action@master type=raw,value={{date 'YYYYMMDD'}}-{{sha}}
with: type=raw,value={{date 'YYYYMMDD'}}
name: ${{ env.REPOSITORY_OWNER }}/${{ env.REPOSITORY_NAME }} type=raw,value=latest
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} - name: Log into registry ${{ env.REGISTRY }}
snapshot: true uses: docker/login-action@v2.1.0
cache: true with:
tags: "latest, ${{ env.RELEASE_VERSION }}" registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.CI_PAT_WRITE_PACKAGE }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true