Skip to content

Commit

Permalink
Use matrix in Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dmohns committed Oct 22, 2024
1 parent aef1ed5 commit f84b67a
Showing 1 changed file with 21 additions and 41 deletions.
62 changes: 21 additions & 41 deletions .github/workflows/release-publish-dockerhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ on:
- published
workflow_dispatch:

env:
IMAGE_NAME_FRONTEND: enaccess/micropowermanager-frontend
IMAGE_NAME_BACKEND: enaccess/micropowermanager-backend

jobs:
release-publish:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- repo: enaccess/micropowermanager-frontend
dockerfile: ./docker/DockerfileUIProd
- repo: enaccess/micropowermanager-backend
dockerfile: ./docker/DockerfileLaravelProd
platform:
- linux/amd64
- linux/arm64

permissions:
contents: read
id-token: write
Expand All @@ -38,58 +46,30 @@ jobs:
VERSION=$(cat version)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check if image tag already exists Frontend
run: |
VERSION="${{ env.VERSION }}"
if docker manifest inspect $IMAGE_NAME_FRONTEND:$VERSION > /dev/null 2>&1; then
echo "Docker image tag $VERSION already exists."
exit 1
else
echo "Docker image tag $VERSION does not exist. Proceeding with build."
fi
- name: Check if image tag already exists Backend
- name: Check if image tag already exists
run: |
VERSION="${{ env.VERSION }}"
if docker manifest inspect $IMAGE_NAME_BACKEND:$VERSION > /dev/null 2>&1; then
if docker manifest inspect ${{ matrix.image.repo }}:$VERSION > /dev/null 2>&1; then
echo "Docker image tag $VERSION already exists."
exit 1
else
echo "Docker image tag $VERSION does not exist. Proceeding with build."
fi
- name: Build and push Docker image Frontend
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
file: ./docker/DockerfileUIProd
platforms: linux/amd64,linux/arm64
file: ${{ matrix.image.dockerfile }}
platforms: ${{ matrix.platform }}
push: true
tags: |
${{ env.IMAGE_NAME_FRONTEND }}:latest
${{ env.IMAGE_NAME_FRONTEND }}:${{ env.VERSION }}
- name: Build and push Docker image Backend
uses: docker/build-push-action@v5
with:
file: ./docker/DockerfileLaravelProd
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE_NAME_BACKEND }}:latest
${{ env.IMAGE_NAME_BACKEND }}:${{ env.VERSION }}
- name: Update Docker Hub Description Frontend
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.IMAGE_NAME_FRONTEND }}
short-description: Open Source Management Tool for Decentralized Utilities
${{ matrix.image.repo }}:latest
${{ matrix.image.repo }}:${{ env.VERSION }}
- name: Update Docker Hub Description Backend
- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.IMAGE_NAME_BACKEND }}
repository: ${{ matrix.image.repo }}
short-description: Open Source Management Tool for Decentralized Utilities

0 comments on commit f84b67a

Please sign in to comment.