-
Notifications
You must be signed in to change notification settings - Fork 23
72 lines (63 loc) · 2.19 KB
/
source-git-automation-on-demand.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Source git Automation Scheduled/On Demand
on:
schedule:
# Workflow runs every 45 minutes
- cron: '*/45 * * * *'
workflow_dispatch:
inputs:
pr-number:
description: 'Pull Request number/s ; when not provided, the workflow will run for all open PRs'
required: true
default: '0'
permissions:
contents: read
jobs:
# Get all open PRs
gather-pull-requests:
if: github.repository == 'redhat-plumbers/systemd-rhel8'
runs-on: ubuntu-latest
outputs:
pr-numbers: ${{ steps.get-pr-numbers.outputs.result }}
pr-numbers-manual: ${{ steps.parse-manual-input.outputs.result }}
steps:
- id: get-pr-numbers
if: inputs.pr-number == '0'
name: Get all open PRs
uses: actions/github-script@v6
with:
# !FIXME: this is not working if there is more than 100 PRs opened
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100
});
return pullRequests.map(pr => pr.number);
- id: parse-manual-input
if: inputs.pr-number != '0'
name: Parse manual input
run: |
echo "result="[ ${{ inputs.pr-number }} ]"" >> $GITHUB_OUTPUT
shell: bash
validate-pr:
name: 'Validation of Pull Request #${{ matrix.pr-number }}'
needs: [ gather-pull-requests ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }}
permissions:
# required for merging PRs
contents: write
# required for PR comments and setting labels
pull-requests: write
steps:
- name: Source-git Automation
uses: redhat-plumbers-in-action/source-git-automation@v1
with:
pr-number: ${{ matrix.pr-number }}
bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}