Skip to content

Commit

Permalink
feat: workflow_dispatch single repo option (#71)
Browse files Browse the repository at this point in the history
* workflow_dispatch single repo option

* Wording

* Comments and vars

* Do not allow workflows in parallel (interrupt)

* Comments
  • Loading branch information
DerekRoberts authored Aug 11, 2023
1 parent ba1d514 commit d493b96
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions .github/workflows/renovate.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
name: Renovate

# Run on pull requests, cronjob or manually (dispatch)
on:
pull_request:
schedule:
- cron: "0 11 * * *" # 3 AM PST = 11 AM UDT
workflow_dispatch:
inputs:
repo: # Optional input
description: org/repo override (optional)
type: string
required: false

# PR open and close use the same group, allowing only one at a time
# Cancel any other workflows (PR, cron or manual)
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}
cancel-in-progress: true

# Variables
env:
config: renovate.json
pr_set: '["bcgov/nr-renovate", "bcgov/quickstart-openshift"]'

jobs:
renovate:
env:
config: renovate.json
Renovate:
permissions:
pull-requests: write
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

# PRs should always use dry run
- name: Set dry run and repo list
# PRs - dry run and a small number of repos
- name: Config for pull requests
if: github.event_name == 'pull_request'
env:
repos: '["bcgov/nr-renovate", "bcgov/quickstart-openshift"]'
run: |
# Dry run and short repo list
cat <<< $(jq '.+= {"dryRun": "full"}' ${{ env.config }}) > ${{ env.config }}
cat <<< $(jq '. | .repositories = ${{ env.repos }}' ${{ env.config }}) > ${{ env.config }}
cat <<< $(jq '. | .repositories = ${{ env.pr_set }}' ${{ env.config }}) > ${{ env.config }}
cat ${{ env.config }} | jq .repositories
# workflow_dispatch - optionally just one repo
- name: Config for manual workflows (optional)
if: inputs.repo
run: |
# Set target repo
cat <<< $(jq '. | .repositories = ["${{ inputs.repo }}"]' ${{ env.config }}) > ${{ env.config }}
cat ${{ env.config }} | jq .repositories
- name: Self-hosted Renovate
# Run Renovate
- name: Run Renovate
uses: renovatebot/github-action@v39.0.1
with:
configurationFile: ${{ env.config }}
Expand Down

0 comments on commit d493b96

Please sign in to comment.