-
Notifications
You must be signed in to change notification settings - Fork 13
98 lines (81 loc) · 2.98 KB
/
Copy pathupdate-compose.yml
File metadata and controls
98 lines (81 loc) · 2.98 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
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
steps:
- name: Checkout target branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/create-github-app-token@v1
name: Generate GitHub token
id: app-token
with:
app-id: ${{ vars.PROTEGEPROJECT_BOT_APP_ID }}
private-key: ${{ secrets.PROTEGEPROJECT_BOT_APP_PRIVATE_KEY }}
- 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: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.WEBPROTEGE_BUMP_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan github.com >> ~/.ssh/known_hosts
- 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 remote set-url origin git@github.com:protegeproject/webprotege-deploy.git
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