Skip to content

Commit

Permalink
Extract reusable workflow for updating consumer repo
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed May 9, 2024
1 parent 7a5535c commit 071181c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 27 deletions.
36 changes: 9 additions & 27 deletions .github/workflows/gradle-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,12 @@ jobs:
commit_message: '[bot] Update develocity-injection reference script as ${{ inputs.version }}'
tagging_message: '${{ inputs.version }}'

release:
needs: update-reference
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main # Include the changes commmited in the previous job

- uses: actions/checkout@v4
with:
repository: 'gradle/actions'
path: actions
token: ${{ secrets.GH_TOKEN }}

- name: Copy reference script
run: cp reference/develocity-injection.init.gradle actions/sources/src/resources/init-scripts/gradle-actions.inject-develocity.init.gradle

# If there are no changes, this action will not create a pull request
- name: Create or update pull request
uses: peter-evans/create-pull-request@v6
with:
branch: bot/develocity-injection-init-script-update
delete-branch: true
commit-message: 'Update develocity-injection init script to ${{ inputs.version }}'
title: 'Update develocity-injection init script'
path: actions
token: ${{ secrets.GH_TOKEN }}
update-gradle-actions:
needs: [update-reference]
uses: ./.github/workflows/gradle-send-update-pr.yml
with:
version: ${{ inputs.version }}
repository: 'gradle/actions'
script-location: 'sources/src/resources/init-scripts/gradle-actions.inject-develocity.init.gradle'
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/gradle-send-update-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Send PR to update consumer

on:
workflow_call:
inputs:
version:
type: string
required: true
repository:
type: string
required: true
script-location:
type: string
required: true
secrets:
GH_TOKEN:
required: true

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main # Include the changes commmited in the previous job

- uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
path: ${{ inputs.repository }}
token: ${{ secrets.GH_TOKEN }}

- name: Copy reference script
run: cp reference/develocity-injection.init.gradle ${{ inputs.repository }}/${{ inputs.script-location }}

# If there are no changes, this action will not create a pull request
- name: Create or update pull request
uses: peter-evans/create-pull-request@v6
with:
branch: bot/develocity-injection-init-script-update
delete-branch: true
commit-message: 'Update develocity-injection init script to ${{ inputs.version }}'
title: 'Update develocity-injection init script'
path: ${{ inputs.repository }}
token: ${{ secrets.GH_TOKEN }}

0 comments on commit 071181c

Please sign in to comment.