-
Notifications
You must be signed in to change notification settings - Fork 7
59 lines (51 loc) · 2.1 KB
/
deploy.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Build and Deploy to Dockerhub
on:
push:
branches:
- auth_rbac
paths-ignore:
- '**.github/workflows/**' # Ignore changes to workflow files
if: "contains(github.event.head_commit.message, '[deploy]')"
jobs:
build-and-push:
if: "contains(github.event.head_commit.message, '[deploy]')"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Read current version
id: read_version
run: |
VERSION=$(cat version.txt)
echo "Current version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Increment version
id: increment_version
run: |
NEW_VERSION=$(awk -F. '{print $1"."($2+1)}' version.txt)
echo "New version: $NEW_VERSION"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo $NEW_VERSION > version.txt
- name: Build and push frontend image
run: |
docker build -t mdv-frontend:${{ env.NEW_VERSION }} -f Dockerfile .
docker tag mdv-frontend:${{ env.NEW_VERSION }} ${{ secrets.DOCKER_HUB_USERNAME }}/mdv-frontend:${{ env.NEW_VERSION }}
docker tag mdv-frontend:${{ env.NEW_VERSION }} ${{ secrets.DOCKER_HUB_USERNAME }}/mdv-frontend:latest
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/mdv-frontend:${{ env.NEW_VERSION }}
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/mdv-frontend:latest
- name: Commit and push new version
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add version.txt
git commit -m "Increment version to ${{ env.NEW_VERSION }} [skip ci]"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}