-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (37 loc) · 1.53 KB
/
ci.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
45
name: Build, Tag, and Push Docker Image to Docker Hub & GHCR
on:
push:
branches:
- master
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get current tag version
id: version
run: |
latest_tag=$(git describe --tags --abbrev=0)
if [ -z "$latest_tag" ]; then
echo "::set-output name=version::v1.0"
else
version_number=$(echo $latest_tag | sed 's/v//')
IFS='.' read -ra version_parts <<< "$version_number"
next_version="${version_parts[0]}.${version_parts[1]}.$((${version_parts[2]} + 1))"
echo "::set-output name=version::v$next_version"
fi
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: gautampatil1
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker image
run: docker build -t gautampatil1/rezume:${{ steps.version.outputs.version }} .
- name: Push Docker image to Docker Hub
run: docker push gautampatil1/rezume:${{ steps.version.outputs.version }}
- name: Push Docker image to ghcr.io
run: |
docker login --username gautampatil1 --password ${{ secrets.GH_PAT }} ghcr.io
docker tag gautampatil1/rezume:${{ steps.version.outputs.version }} ghcr.io/gautampatil1/rezume:${{ steps.version.outputs.version }}
docker push ghcr.io/gautampatil1/rezume:${{ steps.version.outputs.version }}