mirror of
https://github.com/joaovitoriasilva/endurain.git
synced 2026-01-09 15:57:59 -05:00
52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
name: Create backend Docker image on new release or using manual trigger
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
release:
|
|
types:
|
|
- created
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Create a builder
|
|
run: |
|
|
docker buildx create --use
|
|
|
|
- name: Verify app directory exists
|
|
run: |
|
|
if [ ! -d "./app" ]; then
|
|
echo "Directory 'app' does not exist."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Build and push the backend Docker image
|
|
run: |
|
|
if [ "${{ github.event_name }}" == 'workflow_dispatch' ]; then
|
|
IMAGE_TAG="dev_$(date +"%d%m%Y")"
|
|
else
|
|
IMAGE_TAG="${{ github.event.release.tag_name }}"
|
|
fi
|
|
IMAGE_NAME="ghcr.io/${{ github.repository }}/backend"
|
|
|
|
echo ${{ secrets.TOKEN_FOR_ACTIONS }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
|
|
|
|
docker buildx build --platform linux/amd64,linux/arm64 --file backend/Dockerfile --tag $IMAGE_NAME:$IMAGE_TAG --push .
|
|
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
|
|
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
|