-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (38 loc) · 1.18 KB
/
build_and_publish.yml
File metadata and controls
46 lines (38 loc) · 1.18 KB
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
45
46
name: Build and Publish Docker Image
on:
push:
paths:
- 'Dockerfile'
- 'src/**'
branches:
- main
tags:
- 'v*'
env:
PUBLIC_REGISTRY_URL: docker.io/messkon
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker image
run: |
docker build -t unsorted-array-app:latest .
- name: Tag Docker image
run: |
docker tag unsorted-array-app:latest $PUBLIC_REGISTRY_URL/unsorted-array-app:latest
if [ "${{ github.ref_type }}" == "tag" ]; then
docker tag unsorted-array-app:latest $PUBLIC_REGISTRY_URL/unsorted-array-app:${{ github.ref_name }}
fi
- name: Push Docker image
run: |
docker push $PUBLIC_REGISTRY_URL/unsorted-array-app:latest
if [ "${{ github.ref_type }}" == "tag" ]; then
docker push $PUBLIC_REGISTRY_URL/unsorted-array-app:${{ github.ref_name }}
fi