b4420b3f87
docker/login-action@v3 exits 1 against git.farh.net. Replace with a direct docker login shell command using secrets.REGISTRY_TOKEN via --password-stdin. cc @cpfarhood
71 lines
2.1 KiB
YAML
71 lines
2.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, dev, uat]
|
|
pull_request:
|
|
branches: [main, dev, uat]
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
security-events: write
|
|
|
|
env:
|
|
REGISTRY: git.farh.net
|
|
IMAGE_NAME: cartsnitch/auth
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push'
|
|
outputs:
|
|
calver_tag: ${{ steps.calver.outputs.version }}
|
|
sha_tag: sha-${{ github.sha }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Generate CalVer tag
|
|
id: calver
|
|
if: github.ref == 'refs/heads/main'
|
|
run: |
|
|
DATE_TAG=$(date -u +%Y.%m.%d)
|
|
EXISTING=$(git tag -l "v${DATE_TAG}*" | sort -V | tail -1)
|
|
if [ -z "$EXISTING" ]; then VERSION="$DATE_TAG"
|
|
elif [ "$EXISTING" = "v${DATE_TAG}" ]; then VERSION="${DATE_TAG}.2"
|
|
else BUILD_NUM=$(echo "$EXISTING" | sed "s/v${DATE_TAG}\.//"); VERSION="${DATE_TAG}.$((BUILD_NUM + 1))"; fi
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} -u "${{ github.actor }}" --password-stdin
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=sha,prefix=sha-,format=long
|
|
type=raw,value=${{ steps.calver.outputs.version }},enable=${{ github.ref == 'refs/heads/main' }}
|
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Create git tag
|
|
if: github.ref == 'refs/heads/main'
|
|
run: |
|
|
git tag "v${{ steps.calver.outputs.version }}"
|
|
git push origin "v${{ steps.calver.outputs.version }}"
|