Skip to content

feat: process inputs, arrange into array #476

feat: process inputs, arrange into array

feat: process inputs, arrange into array #476

Workflow file for this run

name: Renovate
# Run on pull requests, cronjob or manually (dispatch)
on:
pull_request:
schedule: # 2 AM PST = 10 AM UDT
- cron: "0 10 * * *"
- cron: "0 12 * * *"
- cron: "0 14 * * *"
workflow_dispatch:
inputs:
repos: # Optional input
description: list of repos (org/repo) to override full set
type: string
required: false
# Cancel any other workflows (PR, cron or manual)
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
# Variables
env:
config: renovate.json
pr_set: '["bcgov/nr-renovate", "bcgov/quickstart-openshift"]'
jobs:
Renovate:
permissions:
pull-requests: write
runs-on: ubuntu-22.04
steps:
# Use debug only for input-specified repo runs
# - name: Inputs and variables
# id: vars
# run: |
# if [ -z ${{ inputs.repos }} ]; then
# echo "log-level=INFO" >> $GITHUB_OUTPUT
# else
# echo "log-level=DEBUG" >> $GITHUB_OUTPUT
# fi
# workflow_dispatch - optional inputs
- uses: actions/checkout@v4
- name: Config for manual workflows (optional)
# if: inputs.repos
run: |
# Process inputs into a comma-separated, double-quoted string
# IFS=', ' read -a REPOS <<< "${{ inputs.repos }}"
TEMP_INPUT='bcgov/pubcode, bcgov/quickstart-openshift,bcgov/quickstart-openshift-backends'
IFS=', ' read -a INPUT <<< "$TEMP_INPUT"
REPOS=''
for r in "${INPUT[@]}"; do
REPOS+="\"$r\", "
done
REPOS=${REPOS%,*}
# Set target repos
cat <<< $(jq '. | .repositories = ['${REPOS}']' ${{ env.config }}) > ${{ env.config }}
cat ${{ env.config }} | jq .repositories
exit 1
# PRs - dry run and a small number of repos
- name: Config for pull requests
if: github.event_name == 'pull_request'
run: |
# Dry run and short repo list
cat <<< $(jq '.+= {"dryRun": "full"}' ${{ env.config }}) > ${{ env.config }}
cat <<< $(jq '. | .repositories = ${{ env.pr_set }}' ${{ env.config }}) > ${{ env.config }}
cat ${{ env.config }} | jq .repositories
# Run Renovate
- name: Run Renovate
uses: renovatebot/github-action@v39.0.5
env:
LOG_LEVEL: ${{ steps.vars.outputs.log-level }}
with:
configurationFile: ${{ env.config }}
token: ${{ secrets.RENOVATE_TOKEN }}