Skip to content

Commit

Permalink
Add workflow that updates Argus(-frontend) version in dockerfile
Browse files Browse the repository at this point in the history
This workflow will be triggered by a workflow in Argus or Argus-frontend that is triggered by a new release

This workflow will create a PR with changes to the dockerfile that updates to the newest Argus(-frontend) version
  • Loading branch information
johannaengland committed Aug 16, 2024
1 parent 35159b3 commit 54b0677
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/update-dockerfile-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 }}

0 comments on commit 54b0677

Please sign in to comment.