Merge pull request #2 from fidoriel/master #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
pull_request: | |
push: | |
branches: [master] | |
tags: | |
- "*" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build_docker: | |
name: build docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to ghcr | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract branch name | |
shell: bash | |
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: Docker fe-meta | |
id: fe-meta | |
uses: docker/metadata-action@v4 | |
env: | |
DOCKER_METADATA_PR_HEAD_SHA: true | |
with: | |
images: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
tags: | | |
type=raw,value=${{ steps.extract_branch.outputs.branch }},enable=${{ github.ref != 'refs/heads/master' && steps.extract_branch.outputs.branch != '' }},prefix=fe- | |
type=semver,pattern={{raw}},prefix=fe- | |
type=raw,value=fe-latest,enable=${{ github.ref == 'refs/heads/master' }} | |
- name: Build and push fe | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: frontend/Dockerfile | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: ${{ steps.fe-meta.outputs.tags }} | |
platforms: linux/amd64 | |
- name: Docker be-meta | |
id: be-meta | |
uses: docker/metadata-action@v4 | |
env: | |
DOCKER_METADATA_PR_HEAD_SHA: true | |
with: | |
images: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
tags: | | |
type=raw,value=${{ steps.extract_branch.outputs.branch }},enable=${{ github.ref != 'refs/heads/master' && steps.extract_branch.outputs.branch != '' }},prefix=be- | |
type=semver,pattern={{raw}},prefix=be- | |
type=raw,value=be-latest,enable=${{ github.ref == 'refs/heads/master' }} | |
- name: Build and push be | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: backends/Dockerfile | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: ${{ steps.be-meta.outputs.tags }} | |
platforms: linux/amd64 |