Skip to content

Merge pull request #34 from snypy/compose_v2 #65

Merge pull request #34 from snypy/compose_v2

Merge pull request #34 from snypy/compose_v2 #65

Workflow file for this run

name: build_images
on:
push:
branches:
- 'main'
jobs:
docker:
runs-on: ubuntu-latest
strategy:
matrix:
service: ["api", "static", "ui"]
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check if build and push is required
run: if docker compose pull ${{ matrix.service }}; then echo "SKIP=1" >> $GITHUB_ENV; else echo "SKIP=0" >> $GITHUB_ENV; fi
- name: Build container image
run: docker compose build ${{ matrix.service }}
if: env.SKIP != 1
- name: Push container image
run: docker compose push ${{ matrix.service }}
if: env.SKIP != 1
- name: Dotenv Action
id: dotenv
uses: falti/dotenv-action@v1.0.4
with:
log-variables: true
keys-case: bypass
- name: Tag api container for dockerhub
run: |
docker tag ${{ steps.dotenv.outputs.API_REMOTE }}:${{ steps.dotenv.outputs.API_VERSION }} snypy/backend:${{ steps.dotenv.outputs.API_VERSION }}
docker tag ${{ steps.dotenv.outputs.API_REMOTE }}:${{ steps.dotenv.outputs.API_VERSION }} snypy/backend:latest
if: env.SKIP != 1 && matrix.service == 'api'
- name: Tag static container for dockerhub
run: |
docker tag ${{ steps.dotenv.outputs.STATIC_REMOTE }}:${{ steps.dotenv.outputs.API_VERSION }} snypy/static:${{ steps.dotenv.outputs.API_VERSION }}
docker tag ${{ steps.dotenv.outputs.STATIC_REMOTE }}:${{ steps.dotenv.outputs.API_VERSION }} snypy/static:latest
if: env.SKIP != 1 && matrix.service == 'static'
- name: Tag ui container for dockerhub
run: |
docker tag ${{ steps.dotenv.outputs.UI_REMOTE }}:${{ steps.dotenv.outputs.UI_VERSION }} snypy/frontend:${{ steps.dotenv.outputs.UI_VERSION }}
docker tag ${{ steps.dotenv.outputs.UI_REMOTE }}:${{ steps.dotenv.outputs.UI_VERSION }} snypy/frontend:latest
if: env.SKIP != 1 && matrix.service == 'ui'
- name: Login to dockerhub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push api version container to dockerhub
run: docker push snypy/backend:${{ steps.dotenv.outputs.API_VERSION }}
if: env.SKIP != 1 && matrix.service == 'api'
- name: Push static version container to dockerhub
run: docker push snypy/static:${{ steps.dotenv.outputs.API_VERSION }}
if: env.SKIP != 1 && matrix.service == 'static'
- name: Push ui version container to dockerhub
run: docker push snypy/frontend:${{ steps.dotenv.outputs.UI_VERSION }}
if: env.SKIP != 1 && matrix.service == 'ui'
- name: Push api latest container to dockerhub
run: docker push snypy/backend:latest
if: env.SKIP != 1 && matrix.service == 'api'
- name: Push static latest container to dockerhub
run: docker push snypy/static:latest
if: env.SKIP != 1 && matrix.service == 'static'
- name: Push ui latest container to dockerhub
run: docker push snypy/frontend:latest
if: env.SKIP != 1 && matrix.service == 'ui'