-
-
Notifications
You must be signed in to change notification settings - Fork 20
40 lines (33 loc) · 1.27 KB
/
docker-image_backend_manualORnewrelease.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Create backend Docker image on new release or using manual trigger
on:
#push:
# branches: [ "master" ]
#pull_request:
# branches: [ "master" ]
workflow_dispatch:
release:
types:
- created
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build 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
docker build . --file Dockerfile_backend --tag ${{ github.repository }}/backend:$IMAGE_TAG
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
- name: Push the backend Docker image to GHCR
if: success() && (github.event_name == 'release' || github.event_name == 'workflow_dispatch')
run: |
echo ${{ secrets.TOKEN_FOR_ACTIONS }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
IMAGE_NAME="ghcr.io/${{ github.repository }}/backend"
docker tag ${{ github.repository }}/backend:$IMAGE_TAG $IMAGE_NAME:$IMAGE_TAG
docker push $IMAGE_NAME:$IMAGE_TAG