Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHCR Changes #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
96 changes: 71 additions & 25 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
-
uses: actions/checkout@v4

-
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3

-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true

-
name: Inspect builder
Expand All @@ -49,28 +51,60 @@ jobs:
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"

- name: Generate versions
-
name: Get sopel version
uses: HardNorth/[email protected]
with:
version-source: file
version-file: Dockerfile
version-file-extraction-pattern: '(?<=SOPEL_BRANCH=v).+'

- name: Inspect Version
id: tags
env:
PYTHON_TAG: ${{ matrix.python_images }}
IMAGE: ${{ secrets.DOCKER_SOPEL_IMAGE_NAME }}
version: ${{ env.RELEASE_VERSION }}
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then IMAGE="sopel"; fi
TAGS="${IMAGE}:${version}-py${PYTHON_TAG},${IMAGE}:${version%.*}-py${PYTHON_TAG},${IMAGE}:${version%.*.*}-py${PYTHON_TAG}"
if [[ "x${{ matrix.python_images }}" == "x${{ env.default_python }}" ]] && [[ "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAGS="${TAGS},${IMAGE}:${version},${IMAGE}:${version%.*},${IMAGE}:${version%.*.*},${IMAGE}:latest"
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
TAGS="${IMAGE}:nightly"
fi
echo ::set-output name=tags::${TAGS}
-
name: Docker meta
id: meta-default
uses: docker/metadata-action@v5
if: matrix.python_images == env.default_python
with:
images: |
${{ vars.DOCKER_HUB_IMAGE_NAME }}
ghcr.io/${{ github.repository_owner }}/sopel
flavor: |
latest=true
tags: |
# Python full version
type=semver,pattern={{version}},value=v${{ env.RELEASE_VERSION }},suffix=-py${{ matrix.python_images }}
type=semver,pattern={{major}}.{{minor}},value=v${{ env.RELEASE_VERSION }},suffix=-py${{ matrix.python_images }}
type=semver,pattern={{major}},value=v${{ env.RELEASE_VERSION }},suffix=-py${{ matrix.python_images }}

# Python 3
type=semver,pattern={{major}},value=v${{ env.RELEASE_VERSION }},suffix=-py3
type=semver,pattern={{major}}.{{minor}},value=v${{ env.RELEASE_VERSION }},suffix=-py3
type=semver,pattern={{version}},value=v${{ env.RELEASE_VERSION }},suffix=-py3

# Version only
type=semver,pattern={{major}},value=v${{ env.RELEASE_VERSION }}
type=semver,pattern={{major}}.{{minor}},value=v${{ env.RELEASE_VERSION }}
type=semver,pattern={{version}},value=v${{ env.RELEASE_VERSION }}

type=ref,event=branch

-
name: Docker meta
id: meta-alt-python
uses: docker/metadata-action@v5
if: matrix.python_images != env.default_python
with:
images: |
${{ vars.DOCKER_HUB_IMAGE_NAME }}
ghcr.io/${{ github.repository_owner }}/sopel
flavor: |
latest=false
suffix=-py${{ matrix.python_images }}
tags: |
# Python full version
type=semver,pattern={{version}},value=v${{ env.RELEASE_VERSION }}
type=semver,pattern={{major}}.{{minor}},value=v${{ env.RELEASE_VERSION }}
type=semver,pattern={{major}},value=v${{ env.RELEASE_VERSION }}

-
name: Login to Docker Hub
Expand All @@ -79,27 +113,39 @@ jobs:
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

-
name: Build SOPEL for ${{ matrix.python_images }}
uses: docker/build-push-action@v5
if: github.event_name != 'schedule'
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
build-args: PYTHON_TAG=${{ matrix.python_images }}-alpine
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.tags.outputs.tags }}
tags: ${{ steps.meta-default.outputs.tags }}${{ steps.meta-alt-python.outputs.tags }}
labels: ${{ steps.meta-default.outputs.labels }}${{ steps.meta-alt-python.outputs.labels }}

-
name: Build Nightly SOPEL for ${{ matrix.python_images }}
uses: docker/build-push-action@v5
if: github.event_name == 'schedule' && matrix.python_images == env.default_python
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
build-args: |
PYTHON_TAG=${{ matrix.python_images }}-alpine
SOPEL_BRANCH=master
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.tags.outputs.tags }}
tags: ${{ vars.DOCKER_HUB_IMAGE_NAME }}:nightly,ghcr.io/${{ github.repository_owner }}/sopel:nightly
labels: ${{ steps.meta-default.outputs.labels }}${{ steps.meta-alt-python.outputs.labels }}