-
Notifications
You must be signed in to change notification settings - Fork 13
101 lines (87 loc) · 3.12 KB
/
Copy pathupdate-compose.yml
File metadata and controls
101 lines (87 loc) · 3.12 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Update Compose File
on:
workflow_dispatch:
inputs:
service:
required: true
type: string
version:
required: true
type: string
branch:
required: true
type: string
workflow_call:
inputs:
service:
required: true
type: string
version:
required: true
type: string
branch:
required: true
type: string
jobs:
update-compose:
runs-on: ubuntu-latest
outputs:
service: ${{ steps.set-vars.outputs.service }}
version: ${{ steps.set-vars.outputs.version }}
steps:
- name: Checkout target branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Print inputs for debugging
run: |
echo "Service: ${{ github.event.inputs.service }}"
echo "Version: ${{ github.event.inputs.version }}"
echo "Branch: ${{ github.event.inputs.branch }}"
- name: Update docker-compose image tag
id: update-compose
run: |
SERVICE="${{ github.event.inputs.service }}" # Use the input parameter 'service'
VERSION="${{ github.event.inputs.version }}" # Use the input parameter 'version'
FILE=docker-compose.yml
echo "Updating service '$SERVICE' to version '$VERSION' in $FILE"
# Save the original file checksum
cp "$FILE" "$FILE.bak"
# Attempt to update the image line
sed -i "s|\(image: protegeproject/$SERVICE:\)[^[:space:]]*|\1$VERSION|" "$FILE"
echo "Result:"
grep "image: protegeproject/$SERVICE" "$FILE" || echo "No matching image line found."
# Check if the file was actually changed
if cmp -s "$FILE" "$FILE.bak"; then
echo "No change made to docker-compose.yml."
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "docker-compose.yml updated."
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.update-compose.outputs.changed == 'true'
run: |
git config user.name "webprotege-bot"
git config user.email "webprotege@users.noreply.github.com"
git add docker-compose.yml
git commit -m "chore: bump ${{ github.event.inputs.service }} to ${{ github.event.inputs.version }}"
git push origin ${{ github.event.inputs.branch }}
- name: Set service/version outputs
id: set-vars
run: |
echo "service=${{ github.event.inputs.service }}" >> $GITHUB_OUTPUT
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
notify-deploy:
needs: update-compose
uses: ./.github/workflows/deploy-vm.yml
with:
version: ${{ inputs.version }}
service: ${{ inputs.service }}
branch: ${{ github.event.workflow_run.head_branch }}
secrets:
AZURE_VM_USER: ${{ secrets.AZURE_VM_USER }}
AZURE_VM_HOST: ${{ secrets.AZURE_VM_HOST }}
AZURE_VM_SSH_KEY: ${{ secrets.AZURE_VM_SSH_KEY }}