Skip to content

pre-release

pre-release #5

Workflow file for this run

name: Pre-release
on:
# push:
# branches:
# - main
workflow_dispatch:
env:
REGISTRY: ghcr.io
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
create-pre-release:
runs-on: ubuntu-latest
name: Build and push Docker image and create a new GitHub pre-release
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set environment variables
run: |
echo VERSION=$(cat VERSION).$GITHUB_RUN_NUMBER >> $GITHUB_ENV
echo BASE_IMAGE_NAME=$REGISTRY/$(echo ${GITHUB_REPOSITORY,,}) >> $GITHUB_ENV
echo COMMITED_AT=$(git show -s --format=%cI `git rev-parse HEAD`) >> $GITHUB_ENV
echo REVISION=$(git rev-parse --short HEAD) >> $GITHUB_ENV
- name: Collect Docker image metadata
id: meta-app
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE_NAME }}-app-dev
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=v${{ env.VERSION }}
org.opencontainers.image.maintainer=EBP Schweiz AG
flavor: |
latest=false
tags: |
type=edge
type=semver,pattern=v{{version}},value=${{ env.VERSION }}
- name: Collect Docker image metadata
id: meta-api
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE_NAME }}-api-dev
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=v${{ env.VERSION }}
org.opencontainers.image.maintainer=EBP Schweiz AG
flavor: |
latest=false
tags: |
type=edge
type=semver,pattern=v{{version}},value=${{ env.VERSION }}
- name: Log in to the GitHub container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image (app)
uses: docker/build-push-action@v5
with:
context: ./
file: ./apps/client-asset-sg/docker/Dockerfile
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-app.outputs.tags }}
labels: ${{ steps.meta-app.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-app-dev:edge
cache-to: type=inline
- name: Build and push Docker image (api)
uses: docker/build-push-action@v5
with:
context: ./
file: ./apps/server-asset-sg/docker/Dockerfile
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-api.outputs.tags }}
labels: ${{ steps.meta-api.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-api-dev:edge
cache-to: type=inline
# - name: Create GitHub pre-release
# run: |
# gh api \
# --method POST \
# --header "Accept: application/vnd.github+json" \
# /repos/${GITHUB_REPOSITORY}/releases \
# -f tag_name='v${{ env.VERSION }}' \
# -f target_commitish='main' \
# -f name='${{ env.VERSION }}' \
# -F prerelease=true \