Skip to content

Commit

Permalink
Create PRs instead of merging directly the master
Browse files Browse the repository at this point in the history
  • Loading branch information
evilmarty committed Jan 21, 2024
1 parent 5b7538d commit d2ab934
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 7 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/check-create-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Check and create PR

on:
workflow_call:
inputs:
addon:
required: true
type: string
validate:
type: boolean
default: false
ref:
type: string
outputs:
ref:
value: ${{ jobs.pr.outputs.ref }}
description: The ref of the PR
url:
value: ${{ jobs.pr.outputs.url }}
description: The PR url
version:
value: ${{ jobs.check.outputs.remote_version }}
description: The addon's configured version.
secrets:
token:
required: true
workflow_dispatch:
inputs:
addon:
required: true
type: string
description: The addon slug.
validate:
type: boolean
description: Validate the config and dockerfile versions.

jobs:
check:
name: Check addon for updates
uses: ./.github/workflows/check.yml
with:
addon: ${{ inputs.addon }}
validate: ${{ inputs.validate }}
ref: ${{ inputs.ref }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

pr:
name: Update addon files
needs: check
if: needs.check.outputs.local_version != needs.check.outputs.remote_version
uses: ./.github/workflows/create-pr.yml
with:
addon: ${{ inputs.addon }}
version: ${{ needs.check.outputs.remote_version }}
ref: ${{ inputs.ref }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
56 changes: 56 additions & 0 deletions .github/workflows/create-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Create PR

on:
workflow_call:
inputs:
addon:
required: true
type: string
version:
required: true
type: string
ref:
type: string
outputs:
url:
value: ${{ jobs.pr.outputs.url }}
description: The PR url
ref:
value: ${{ jobs.pr.outputs.ref }}
description: The ref of the PR
secrets:
token:
required: true

jobs:
pr:
runs-on: ubuntu-latest
outputs:
url: ${{ steps.create.outputs.pull-request-url }}
ref: ${{ steps.create.outputs.pull-request-head-sha }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
token: ${{ secrets.token }}
- name: Update files
env:
NEW_VERSION: ${{ inputs.version }}
CONFIG_FILE: "${{ inputs.addon }}/config.json"
DOCKERFILE: "${{ inputs.addon }}/Dockerfile"
run: |
jq --arg version "$NEW_VERSION" '. + {version: $version}' "$CONFIG_FILE" > "${CONFIG_FILE}.new"
sed -i -e "/^FROM/s/:.*/:${NEW_VERSION}/" "$DOCKERFILE"
mv -f "${CONFIG_FILE}.new" "$CONFIG_FILE"
- id: create
name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.token }}
branch: "update/${{ inputs.addon }}/${{ inputs.version }}"
delete-branch: true
path: "${{ inputs.addon }}/"
labels: docker,addon
commit-message: "Version bump ${{ inputs.addon }} to ${{ inputs.version }}"
title: "Version bump ${{ inputs.addon }} to ${{ inputs.version }}"
committer: "github-actions <[email protected]>"
8 changes: 1 addition & 7 deletions .github/workflows/scheduled-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@ on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
inputs:
publish:
type: boolean
default: true
description: Publish the updated addons.

jobs:
main:
strategy:
matrix:
addon: [ sabnzbd, sonarr, radarr, lidarr ]
uses: ./.github/workflows/check-update-build.yml
uses: ./.github/workflows/check-create-pr.yml
with:
addon: ${{ matrix.addon }}
publish: ${{ github.event_name == 'schedule' || inputs.publish }}
ref: ${{ github.ref }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit d2ab934

Please sign in to comment.