-
-
Notifications
You must be signed in to change notification settings - Fork 14
40 lines (35 loc) · 1.27 KB
/
docker-image.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: Docker Image CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Declare env variables
id: vars
shell: bash
run: |
GITHUB_REF=${GITHUB_REF#refs/tags/}
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
CURRENT_VERSION=`grep -o "'.*'" nseta/__init__.py | sed "s/'//g"`
THIS_VERSION=${CURRENT_VERSION}.${{github.run_number}}
echo "##[set-output name=THIS_VERSION;]$(echo ${THIS_VERSION})"
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish latest image to Docker Hub
run: |
docker build . -f Dockerfile -t pkjmesra/nseta:latest
docker push pkjmesra/nseta:latest
- name: Publish release version image to Docker Hub
if: startsWith(github.ref, 'refs/tags')
run: |
docker build . -f Dockerfile -t pkjmesra/nseta:${{ steps.vars.outputs.THIS_VERSION }}
docker push pkjmesra/nseta:${{ steps.vars.outputs.THIS_VERSION }}