-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (63 loc) · 2.41 KB
/
generate_prs.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
---
name: Generate Downstream PRs
on:
workflow_dispatch:
inputs:
message:
description: "Message to include in the generated commits:"
required: true
dry-run:
description: "Dry Run (PRs are not generated)"
type: boolean
default: true
jobs:
create-prs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # tag=v25
- name: Install Ansible
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt update && \
sudo apt install -y software-properties-common && \
sudo apt-add-repository ppa:ansible/ansible -y && \
sudo apt install -y ansible
# NOTE (@NickLarsenNZ): This could be removed in favor of nix-shell and rrbutani/use-nix-shell-action
- name: Install deps for operators
run: |
sudo apt-get install \
protobuf-compiler \
krb5-user \
libclang-dev \
libkrb5-dev \
liblzma-dev \
libssl-dev \
pkg-config
- name: Install jinja2
run: pip install -r requirements.txt
# Create commit message depending on whether this is run manually or due to a scheduled run
- name: Set commit message for manual dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "REASON=Manual run triggered by: ${{ github.event.sender.login }} with message [${{ github.event.inputs.message }}]" >> "$GITHUB_ENV"
- name: Set commit message for schedule
if: ${{ github.event_name == 'schedule' }}
run: |
echo "REASON=Daily run triggered" >> "$GITHUB_ENV"
# Generate PRs
- name: Run playbook
if: ${{ !inputs.dry-run }}
run: |
# Funnel via JSON to ensure that values are escaped properly
echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, reason: $ENV.REASON, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json
ansible-playbook playbook/playbook.yaml --extra-vars "@vars.json"
env:
GH_ACCESS_TOKEN: ${{ secrets.gh_access_token }}
# Do Not Generate PRs
- name: Run playbook (dry-run)
if: ${{ inputs.dry-run }}
run: ./test.sh
env:
GH_ACCESS_TOKEN: ""