Update Docker publish workflow to streamline process

Refactor GitHub Actions workflow to build and push Docker image directly, removing unnecessary steps and outputs.
This commit is contained in:
Amos 2025-09-06 12:35:39 +01:00 committed by GitHub
parent ff460f2d2e
commit ecf49bdfae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
name: Build and Publish Docker Image
name: Build and Push Docker Image
on:
push:
@ -8,21 +8,18 @@ on:
workflow_dispatch:
jobs:
build:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
@ -33,63 +30,21 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/plutainer
images: ghcr.io/${{ github.repository }}/plutainer
tags: |
type=schedule
type=ref,event=branch
# tag for pushes to main branch
type=branch,event=push,pattern=latest
# tag for releases
type=ref,event=tag
# tag for pull requests
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Add 'latest' tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# tag with commit sha
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/image.tar
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: docker-image
path: /tmp/image.tar
retention-days: 1
publish:
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
if: github.event_name == 'push' || github.event_name == 'release'
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: docker-image
path: /tmp
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load Docker image
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: Push Docker image
run: |
echo "Pushing tags: ${{ needs.build.outputs.tags }}"
docker push --all-tags ghcr.io/${{ github.repository_owner }}/plutainer