-
Notifications
You must be signed in to change notification settings - Fork 7
63 lines (53 loc) · 2.04 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
60
61
62
63
name: Build and Deploy to Docker Hub
on:
push:
branches:
- auth_rbac
paths-ignore:
- '**.github/workflows/**' # Ignore changes to workflow files
workflow_dispatch: # Allows manual trigger for testing
jobs:
build-and-push:
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[deploy]') # Condition to check the commit message
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- 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 multi-architecture image
run: |
echo "Building and pushing multi-architecture image for linux/amd64 and linux/arm64..."
docker buildx build --platform linux/amd64,linux/arm64 \
-t ${{ secrets.DOCKER_HUB_USERNAME }}/mdv-frontend:${{ env.NEW_VERSION }} \
-t ${{ secrets.DOCKER_HUB_USERNAME }}/mdv-frontend:latest \
--push .
- 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 }}