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

Improve docker image deployment action #254

Merged
merged 2 commits into from
Oct 2, 2024
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
71 changes: 43 additions & 28 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,83 +7,98 @@ on:

jobs:
build-release:
name: GitHub Container Registry
if: "!github.event.release.prerelease"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: v0.1

- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_LOGIN }}
password: ${{ secrets.GHCR_PASSWORD }}

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

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

- name: Extract metadata (tags, labels) for Docker
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/buggregator/server
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: ./
platforms: linux/amd64,linux/arm64
file: ./.docker/Dockerfile
push: true
build-args: |
APP_VERSION=${{ steps.previoustag.outputs.tag }}
APP_VERSION=${{ github.ref_name }}
FRONTEND_IMAGE_TAG=latest
tags:
ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ steps.previoustag.outputs.tag }}
BRANCH=${{ github.ref_name }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

build-docker-release:
name: Docker Hub
if: "!github.event.release.prerelease"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: v0.1

- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

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

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

- name: Extract metadata (tags, labels) for Docker
id: docker_meta
uses: docker/metadata-action@v5
with:
images: butschster/buggregator
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: ./
platforms: linux/amd64,linux/arm64
file: ./.docker/Dockerfile
push: true
build-args:
APP_VERSION=${{ steps.previoustag.outputs.tag }}
build-args: |
APP_VERSION=${{ github.ref_name }}
FRONTEND_IMAGE_TAG=latest
BRANCH=${{ steps.previoustag.outputs.tag }}
tags:
${{ secrets.DOCKER_HUB_USERNAME }}/buggregator:latest, ${{ secrets.DOCKER_HUB_USERNAME }}/buggregator:${{ steps.previoustag.outputs.tag }}
BRANCH=${{ github.ref_name }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Loading