forked from PRODYNA/delete-from-enterprise
-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (34 loc) · 1.35 KB
/
build.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
41
42
43
44
name: Docker Image CI
on:
push:
branches: [ "main" ]
tags:
- 'v*'
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ghcr.io/prodyna/sync-enterprise:latest
# if tag, get the tag as variable
- name: Get tag if available
if: startsWith(github.ref, 'refs/tags/v')
run: echo "tag=${GITHUB_REF#refs/tags/*}" >> $GITHUB_ENV
# Login to the GitHub Container Registry
- name: Login to the GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }}
# Push latest to GitHub Container Registry
- name: Push the latest Docker image to the GitHub Container Registry
run: docker push ghcr.io/prodyna/sync-enterprise:latest
# if tagged, push the image to the GitHub Container Registry
- name: Tag with git tag and push to GitHub Container Registry
# only if it is a tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
docker tag ghcr.io/prodyna/sync-enterprise:latest ghcr.io/prodyna/sync-enterprise:${{ env.tag }}
docker push ghcr.io/prodyna/sync-enterprise:${{ env.tag }}