Generate Downstream PRs (dry-run: false) #123
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 }} | |
# If you add a new repository here, also add it to config/repositories.yaml | |
matrix: | |
repository: | |
- name: airflow-operator | |
pretty_string: Apache Airflow | |
product_string: airflow | |
url: stackabletech/airflow-operator.git | |
- name: commons-operator | |
include_productconfig: false | |
has_product: false | |
pretty_string: Stackable Commons | |
product_string: commons | |
url: stackabletech/commons-operator.git | |
- name: druid-operator | |
pretty_string: Apache Druid | |
product_string: druid | |
url: stackabletech/druid-operator.git | |
- name: hbase-operator | |
pretty_string: Apache HBase | |
product_string: hbase | |
url: stackabletech/hbase-operator.git | |
- name: hdfs-operator | |
pretty_string: Apache HDFS | |
product_string: hdfs | |
url: stackabletech/hdfs-operator.git | |
- name: hello-world-operator | |
pretty_string: Hello World | |
product_string: hello | |
url: stackabletech/hello-world-operator.git | |
- name: hive-operator | |
pretty_string: Apache Hive | |
product_string: hive | |
url: stackabletech/hive-operator.git | |
- name: kafka-operator | |
pretty_string: Apache Kafka | |
product_string: kafka | |
url: stackabletech/kafka-operator.git | |
- name: nifi-operator | |
pretty_string: Apache NiFi | |
product_string: nifi | |
url: stackabletech/nifi-operator.git | |
- name: listener-operator | |
include_productconfig: false | |
has_product: false | |
pretty_string: Stackable Listener Operator | |
product_string: listener-operator | |
run_as: custom | |
url: stackabletech/listener-operator.git | |
- name: opa-operator | |
extra_crates: | |
- stackable-opa-bundle-builder | |
pretty_string: OpenPolicyAgent | |
product_string: opa | |
url: stackabletech/opa-operator.git | |
- name: secret-operator | |
include_productconfig: false | |
has_product: false | |
pretty_string: Stackable Secret Operator | |
product_string: secret-operator | |
run_as: custom | |
url: stackabletech/secret-operator.git | |
- name: spark-k8s-operator | |
pretty_string: Apache Spark-on-Kubernetes | |
product_string: spark-k8s | |
url: stackabletech/spark-k8s-operator.git | |
- name: superset-operator | |
pretty_string: Apache Superset | |
product_string: superset | |
url: stackabletech/superset-operator.git | |
- name: trino-operator | |
pretty_string: Trino | |
product_string: trino | |
url: stackabletech/trino-operator.git | |
- name: zookeeper-operator | |
pretty_string: Apache ZooKeeper | |
product_string: zookeeper | |
url: stackabletech/zookeeper-operator.git | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
persist-credentials: false | |
- uses: cachix/install-nix-action@754537aaedb35f72ab11a60cc162c49ef3016495 # v31.2.0 | |
- 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: Overwrite repositories.yaml for ${{ matrix.repository.name }} | |
run: | | |
cat >config/repositories.yaml <<CONFIG | |
--- | |
repositories: | |
- ${{ toJSON(matrix.repository) }} | |
CONFIG | |
# For debugging | |
cat config/repositories.yaml | |
# Generate PRs | |
- name: Run playbook | |
if: ${{ !inputs.dry-run }} | |
env: | |
CUSTOM_PR_TITLE: ${{ inputs.custom-pr-title }} | |
GH_ACCESS_TOKEN: ${{ secrets.gh_access_token }} | |
run: | | |
# Funnel via JSON to ensure that values are escaped properly | |
# Check if custom PR title is set. If so, insert it into the extra vars | |
if [ -n "$CUSTOM_PR_TITLE" ]; then | |
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}' --arg pwd "$(pwd)" > vars.json | |
else | |
echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json | |
fi | |
ansible-playbook playbook/playbook.yaml --extra-vars "@vars.json" | |
# Do Not Generate PRs | |
- name: Run playbook (dry-run) | |
if: ${{ inputs.dry-run }} | |
run: ./test.sh | |
env: | |
GH_ACCESS_TOKEN: "" |