Skip to content

Merge pull request #89 from SprocketBot/codex/sanitize-ghcr-branch-tags #248

Merge pull request #89 from SprocketBot/codex/sanitize-ghcr-branch-tags

Merge pull request #89 from SprocketBot/codex/sanitize-ghcr-branch-tags #248

Workflow file for this run

name: Docker Image CI
on:
workflow_dispatch:
push:
branches: [ "main", "staging", "dev" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/sprocketbot/elo-service
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract image tag
shell: bash
run: |
raw_ref="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
safe_tag="$(echo "$raw_ref" | tr '[:upper:]' '[:lower:]' | sed 's|[^a-z0-9._-]|-|g')"
echo "branch=$safe_tag" >> "$GITHUB_OUTPUT"
id: extract_branch
- name: Build And Push Image
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.IMAGE_NAME }}:${{ steps.extract_branch.outputs.branch }}
platforms: linux/amd64