Skip to content

Update update-image-tag.yaml #45

Update update-image-tag.yaml

Update update-image-tag.yaml #45

name: Build and Push Docker Image
on:
push:
branches:
- main
env:
IMAGE_NAME: event-buddy
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get release version
id: release-version
run: |
VERSION=$(grep -oP '"version":\s*"\K[^"]+' package.json)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Build image
run: docker build --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" .
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
env:
VERSION: ${{ steps.release-version.outputs.VERSION }}
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Create Release
uses: elgohr/Github-Release-Action@v5
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: ${{ steps.release-version.outputs.VERSION }}
tag: ${{ steps.release-version.outputs.VERSION }}