-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (44 loc) · 2.07 KB
/
update-dockerfile-on-release.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
name: Change docker-compose.yml on release in Argus/Argus-frontend
on:
repository_dispatch:
types: [trigger-release]
jobs:
change-dockerfile-on-release:
runs-on: ubuntu-latest
if: ${{ github.event.client_payload.repository }} == "Argus" || ${{ github.event.client_payload.repository }} == "Argus-frontend"
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Copy repository name & version into environment variables
run: |
repository="${{ github.event.client_payload.repository }}"
version="${{ github.event.client_payload.version }}"
# Remove 'v' from version (e.g. v1.14.0 -> 1.14.0)
version="${version:1}"
# Make repository name lowercase
repository="${repository,}"
echo "REPOSITORY=$repository" >> $GITHUB_ENV
echo "VERSION=$version" >> $GITHUB_ENV
- name: Create and switch to new branch
run: |
git switch -c update-${{ env.REPOSITORY }}-v${{ env.VERSION }}
- name: Change version number in docker-compose.yml to newest
run: |
sed -i -e 's/${{ env.REPOSITORY }}:[0-9]\+.[0-9]\+.[0-9]\+/${{ env.REPOSITORY }}:${{ env.VERSION }}/' docker-compose.yml
- name: Add, commit and push changes
run: |
git config user.email "[email protected]"
git config user.name "Release update bot"
git add "docker-compose.yml"
git commit -m "Update ${{ env.REPOSITORY }} version to ${{ env.VERSION }}"
git push -u origin update-${{ env.REPOSITORY }}-v${{ env.VERSION }}
- name: Create pull request
run: |
gh pr create -B master -H update-${{ env.REPOSITORY }}-v${{ env.VERSION }} \
--title 'Update ${{ env.REPOSITORY }} version to ${{ env.VERSION }} in docker-compose.yml' \
--body 'Created by GitHub action, triggered by a release in ${{ env.REPOSITORY }} of version ${{ env.VERSION }}'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}