-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (38 loc) · 1.23 KB
/
backend_publish.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
name: Publish Docker Image
on:
push:
branches:
- main
workflow_dispatch: # Manual trigger
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '21'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine Image Tag
id: tag
run: |
# Try to find a Git tag, otherwise use the short commit hash
TAG=$(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD)
echo "Tag or Commit: $TAG"
echo "::set-output name=image_tag::$TAG"
- name: Build and Publish Docker Image
run: |
./backend/gradlew bootBuildImage --imageName=ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.image_tag }}
./backend/gradlew bootBuildImage --imageName=ghcr.io/${{ github.repository }}:latest
- name: Verify image
run: docker images