Add push to dockerhub
This commit is contained in:
81
.github/workflows/ci.yml
vendored
81
.github/workflows/ci.yml
vendored
@@ -10,10 +10,6 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: ghcr.io
|
|
||||||
IMAGE_NAME: donkie/spoolman
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
#
|
#
|
||||||
# Linting
|
# Linting
|
||||||
@@ -123,7 +119,7 @@ jobs:
|
|||||||
- name: Log in to the Github Container registry
|
- name: Log in to the Github Container registry
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v3.3.0
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
@@ -132,10 +128,10 @@ jobs:
|
|||||||
uses: docker/build-push-action@v6.7.0
|
uses: docker/build-push-action@v6.7.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
tags: ${{ env.IMAGE_NAME }}:test
|
tags: ${{ vars.GHCR_IMAGE }}:test
|
||||||
outputs: type=docker,dest=/tmp/spoolman.tar
|
outputs: type=docker,dest=/tmp/spoolman.tar
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64
|
cache-from: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-amd64
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64,mode=max
|
cache-to: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-amd64,mode=max
|
||||||
|
|
||||||
# Separate build for pull requests since PRs dont have access to store cache
|
# Separate build for pull requests since PRs dont have access to store cache
|
||||||
- name: Build Spoolman (PR)
|
- name: Build Spoolman (PR)
|
||||||
@@ -143,9 +139,9 @@ jobs:
|
|||||||
uses: docker/build-push-action@v6.7.0
|
uses: docker/build-push-action@v6.7.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
tags: ${{ env.IMAGE_NAME }}:test
|
tags: ${{ vars.GHCR_IMAGE }}:test
|
||||||
outputs: type=docker,dest=/tmp/spoolman.tar
|
outputs: type=docker,dest=/tmp/spoolman.tar
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64
|
cache-from: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-amd64
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4.4.0
|
uses: actions/upload-artifact@v4.4.0
|
||||||
@@ -167,7 +163,7 @@ jobs:
|
|||||||
- name: Log in to the Github Container registry
|
- name: Log in to the Github Container registry
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v3.3.0
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
@@ -176,10 +172,10 @@ jobs:
|
|||||||
uses: docker/build-push-action@v6.7.0
|
uses: docker/build-push-action@v6.7.0
|
||||||
with:
|
with:
|
||||||
context: ./tests_integration
|
context: ./tests_integration
|
||||||
tags: ${{ env.IMAGE_NAME }}-tester:latest
|
tags: ${{ vars.GHCR_IMAGE }}-tester:latest
|
||||||
outputs: type=docker,dest=/tmp/spoolman-tester.tar
|
outputs: type=docker,dest=/tmp/spoolman-tester.tar
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-tester
|
cache-from: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-tester
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-tester,mode=max
|
cache-to: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-tester,mode=max
|
||||||
|
|
||||||
# Separate build for pull requests since PRs dont have access to store cache
|
# Separate build for pull requests since PRs dont have access to store cache
|
||||||
- name: Build Spoolman Tester (PR)
|
- name: Build Spoolman Tester (PR)
|
||||||
@@ -187,9 +183,9 @@ jobs:
|
|||||||
uses: docker/build-push-action@v6.7.0
|
uses: docker/build-push-action@v6.7.0
|
||||||
with:
|
with:
|
||||||
context: ./tests_integration
|
context: ./tests_integration
|
||||||
tags: ${{ env.IMAGE_NAME }}-tester:latest
|
tags: ${{ vars.GHCR_IMAGE }}-tester:latest
|
||||||
outputs: type=docker,dest=/tmp/spoolman-tester.tar
|
outputs: type=docker,dest=/tmp/spoolman-tester.tar
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-tester
|
cache-from: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-tester
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4.4.0
|
uses: actions/upload-artifact@v4.4.0
|
||||||
@@ -254,7 +250,7 @@ jobs:
|
|||||||
- name: Log in to the Github Container registry
|
- name: Log in to the Github Container registry
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v3.3.0
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
@@ -263,8 +259,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/arm64
|
platforms: linux/arm64
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64
|
cache-from: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-arm64
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64,mode=max
|
cache-to: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-arm64,mode=max
|
||||||
#
|
#
|
||||||
# Build arm/v7 image
|
# Build arm/v7 image
|
||||||
# Don't run this for pull requests
|
# Don't run this for pull requests
|
||||||
@@ -293,7 +289,7 @@ jobs:
|
|||||||
- name: Log in to the Github Container registry
|
- name: Log in to the Github Container registry
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v3.3.0
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
@@ -302,10 +298,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/arm/v7
|
platforms: linux/arm/v7
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-armv7
|
cache-from: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-armv7
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-armv7,mode=max
|
cache-to: type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-armv7,mode=max
|
||||||
#
|
#
|
||||||
# Release image if tests pass
|
# Release images GHCR and Docker Hub if tests pass
|
||||||
# Don't run this for pull requests
|
# Don't run this for pull requests
|
||||||
#
|
#
|
||||||
publish-images:
|
publish-images:
|
||||||
@@ -331,22 +327,41 @@ jobs:
|
|||||||
- name: Log in to the Github Container registry
|
- name: Log in to the Github Container registry
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v3.3.0
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for GHCR
|
||||||
id: meta
|
id: meta-ghcr
|
||||||
uses: docker/metadata-action@v5.5.1
|
uses: docker/metadata-action@v5.5.1
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
ghcr.io/${{ vars.GHCR_IMAGE }}
|
||||||
tags: |
|
tags: |
|
||||||
type=edge
|
type=edge
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker Hub
|
||||||
|
id: meta-dh
|
||||||
|
uses: docker/metadata-action@v5.5.1
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ vars.REMOTE_REGISTRY_URL }}/${{ vars.REMOTE_REGISTRY_NAMESPACE }}/${{ vars.REMOTE_REGISTRY_REPOSITORY }}
|
||||||
|
tags: |
|
||||||
|
type=edge
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
|
- name: Log in to DockerHub
|
||||||
|
uses: docker/login-action@v3.3.0
|
||||||
|
with:
|
||||||
|
registry: ${{ vars.REMOTE_REGISTRY_URL }}
|
||||||
|
username: ${{ secrets.REMOTE_REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REMOTE_REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
- name: Store git commit and build date
|
- name: Store git commit and build date
|
||||||
run: |
|
run: |
|
||||||
echo "GIT_COMMIT=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
|
echo "GIT_COMMIT=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
|
||||||
@@ -358,15 +373,17 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: |
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
${{ steps.meta-ghcr.outputs.tags }}
|
||||||
|
${{ steps.meta-dh.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta-ghcr.outputs.labels }}
|
||||||
build-args: |
|
build-args: |
|
||||||
GIT_COMMIT
|
GIT_COMMIT
|
||||||
BUILD_DATE
|
BUILD_DATE
|
||||||
cache-from: |
|
cache-from: |
|
||||||
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64
|
type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-amd64
|
||||||
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64
|
type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-arm64
|
||||||
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-armv7
|
type=registry,ref=ghcr.io/${{ vars.GHCR_IMAGE }}:buildcache-armv7
|
||||||
#
|
#
|
||||||
# Create Github Release if CI was triggered by a tag
|
# Create Github Release if CI was triggered by a tag
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user