Generate Downstream PRs (dry-run: false) #132
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Generate Downstream PRs | |
run-name: "Generate Downstream PRs (dry-run: ${{ inputs.dry-run }})" | |
on: | |
workflow_dispatch: | |
inputs: | |
message: | |
description: "Message to include in the generated commits:" | |
required: true | |
custom-pr-title: | |
description: "Optionally a custom PR title. If unset, default will be used" | |
dry-run: | |
description: "Dry Run (PRs are not generated)" | |
type: boolean | |
default: true | |
fail-fast: | |
description: "Fail fast (if one job fails, all other are cancelled)" | |
type: boolean | |
default: false | |
permissions: {} | |
jobs: | |
create-prs: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: ${{ inputs.fail-fast }} | |
matrix: | |
# This should be the list of repository names from config/repositories.yaml: | |
# yq '.repositories | map(.name)' config/repositories.yaml | |
repository: | |
- airflow-operator | |
- commons-operator | |
- druid-operator | |
- hbase-operator | |
- hdfs-operator | |
- hive-operator | |
- kafka-operator | |
- nifi-operator | |
- listener-operator | |
- opa-operator | |
- opensearch-operator | |
- secret-operator | |
- spark-k8s-operator | |
- superset-operator | |
- trino-operator | |
- zookeeper-operator | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
persist-credentials: false | |
- uses: cachix/install-nix-action@f0fe604f8a612776892427721526b4c7cfb23aba # v31.4.1 | |
- 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' }} | |
env: | |
REASON: ${{ github.event.inputs.message }} | |
AUTHOR: ${{ github.event.sender.login }} | |
run: | | |
echo "AUTHOR=$AUTHOR" >> "$GITHUB_ENV" | |
echo "REASON=$REASON" >> "$GITHUB_ENV" | |
- name: Set commit message for schedule | |
if: ${{ github.event_name == 'schedule' }} | |
run: | | |
echo "AUTHOR=stackabletech/developers" | |
echo "REASON=Daily run triggered" >> "$GITHUB_ENV" | |
- name: Run playbook | |
env: | |
CUSTOM_PR_TITLE: ${{ inputs.custom-pr-title }} | |
GH_ACCESS_TOKEN: ${{ secrets.gh_access_token }} | |
REPOSITORY: ${{ matrix.repository }} | |
# tags local excludes all actions that actually generate PRs | |
DRY_RUN_FLAGS: ${{ inputs.dry-run && '--tags=local' || '' }} | |
# shellsheck disable=SC2086 | |
run: | | |
echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, custom_pr_title: $ENV.CUSTOM_PR_TITLE, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN, shard_repositories: [$ENV.REPOSITORY]} | with_entries(select(.value != null and .value != ""))' --arg pwd "$(pwd)" > vars.json | |
# $DRY_RUN_FLAGS is intentionally not quoted, since we need to avoid | |
# passing an argument if we're not in dry mode. | |
# This is safe, since it always has one of two hard-coded values. | |
# shellcheck disable=SC2086 | |
ansible-playbook playbook/playbook.yaml --extra-vars "@vars.json" $DRY_RUN_FLAGS |