Rework GitHub Actions Workflow

This commit is contained in:
duhow
2023-04-10 17:01:49 +02:00
parent 9cdca7c7aa
commit 80b56bcdd7
2 changed files with 44 additions and 21 deletions

View File

@@ -1,9 +0,0 @@
if [[ $GIT_BRANCH != 'master' ]]; then
docker buildx build --push\
--tag zurdi15/romm:dev-latest --tag zurdi15/romm:dev-${VERSION}\
--platform linux/arm64 . --file ./docker/Dockerfile
else
docker buildx build --push\
--tag zurdi15/romm:latest --tag zurdi15/romm:${VERSION}\
--platform linux/arm64,linux/amd64 . --file ./docker/Dockerfile
fi

View File

@@ -11,20 +11,52 @@ on:
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set environment variables
run: echo "GIT_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Install buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
version: latest
- name: Login to docker hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Build the image
shell: bash
run: ./.github/actions/build.sh
env:
VERSION: ${{ inputs.version }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
name=zurdi15/romm
name=ghcr.io/zurdi15/romm
flavor: |
# latest on master branch, prefix dev on other branches
latest=${{ github.ref == format('refs/heads/{0}', 'master') }}
prefix=${{ github.ref != format('refs/heads/{0}', 'master') && 'dev-' || '' }}
tags: |
type=raw,value=latest
type=raw,value=${{ inputs.version }}
labels: |
org.opencontainers.image.version=${{ inputs.version }}
- name: Build image
uses: docker/build-push-action@v4
with:
file: docker/Dockerfile
context: .
push: true
platforms: linux/arm64,linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}