Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,42 @@ on:
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 Docker Hub
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_access_token }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT"
id: extract_branch

- name: Build And Push Image
uses: docker/build-push-action@v3
with:
push: true
tags: ${{secrets.docker_username}}/elo-service:${{ steps.extract_branch.outputs.branch }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.IMAGE_NAME }}:${{ steps.extract_branch.outputs.branch }}
platforms: linux/amd64
Loading