-
Notifications
You must be signed in to change notification settings - Fork 2
86 lines (72 loc) · 2.37 KB
/
docker-image-local.yml
File metadata and controls
86 lines (72 loc) · 2.37 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Build and push Docker image (local)
on:
push:
branches:
- main
paths:
- 'backend/**'
workflow_dispatch:
inputs:
target_branch:
description: 'Local branch to merge into (default: local)'
required: false
default: 'local'
permissions:
contents: write
jobs:
merge-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: Set target branch
run: echo "TARGET_BRANCH=${{ github.event.inputs.target_branch || 'local' }}" >> $GITHUB_ENV
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Fetch branches
run: |
git fetch origin main
git fetch origin $TARGET_BRANCH || true
- name: Checkout target branch
run: |
if git rev-parse --verify origin/$TARGET_BRANCH >/dev/null 2>&1; then
git checkout -B $TARGET_BRANCH origin/$TARGET_BRANCH
else
git checkout -B $TARGET_BRANCH
fi
- name: Merge main into target branch
run: |
set -o pipefail
if git merge --no-edit origin/main; then
echo "Merge succeeded"
else
echo "Merge failed. Showing status and conflicted files:" >&2
git status --porcelain
git --no-pager diff --name-only --diff-filter=U || true
exit 1
fi
- name: Push merged branch
run: git push origin HEAD:$TARGET_BRANCH
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Build with Maven
run: mvn -DskipTests package
working-directory: backend
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/transformer-tracker-local:latest .
working-directory: backend
- name: Push image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/transformer-tracker-local:latest