68 lines
1.9 KiB
YAML
68 lines
1.9 KiB
YAML
name: Docker Publish
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
REGISTRY: gitea.theriise.net
|
|
IMAGE_WEB: gitea.theriise.net/steinhelge/pong-web
|
|
IMAGE_LOBBY: gitea.theriise.net/steinhelge/pong-lobby
|
|
|
|
jobs:
|
|
publish-images:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set image tags
|
|
id: meta
|
|
shell: bash
|
|
run: |
|
|
short_sha="$(git rev-parse --short=12 HEAD)"
|
|
echo "short_sha=$short_sha" >> "$GITHUB_OUTPUT"
|
|
if tag_name="$(git describe --tags --exact-match 2>/dev/null)"; then
|
|
echo "version_tag=$tag_name" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "version_tag=sha-$short_sha" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Login to registry
|
|
shell: bash
|
|
env:
|
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
run: |
|
|
test -n "$REGISTRY_USER"
|
|
test -n "$REGISTRY_PASSWORD"
|
|
echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin
|
|
|
|
- name: Build and push web image
|
|
shell: bash
|
|
run: |
|
|
docker build \
|
|
-f Dockerfile \
|
|
-t "$IMAGE_WEB:${{ steps.meta.outputs.version_tag }}" \
|
|
-t "$IMAGE_WEB:latest" \
|
|
.
|
|
docker push "$IMAGE_WEB:${{ steps.meta.outputs.version_tag }}"
|
|
docker push "$IMAGE_WEB:latest"
|
|
|
|
- name: Build and push lobby image
|
|
shell: bash
|
|
run: |
|
|
docker build \
|
|
-f Dockerfile.lobby \
|
|
-t "$IMAGE_LOBBY:${{ steps.meta.outputs.version_tag }}" \
|
|
-t "$IMAGE_LOBBY:latest" \
|
|
.
|
|
docker push "$IMAGE_LOBBY:${{ steps.meta.outputs.version_tag }}"
|
|
docker push "$IMAGE_LOBBY:latest"
|