Update Active Policy List #1278
This file contains 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: Update Active Policy List | |
# https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_run | |
# https://stackoverflow.com/questions/58457140/dependencies-between-workflows-on-github-actions | |
on: | |
# Trigger this workflow when "Test Policies" completes successfully. after running against the "master" branch | |
# This mitigates publishing broken policies | |
workflow_run: | |
workflows: ["Test Policies"] | |
branches: [master] | |
types: | |
- completed | |
# Workflow dispatch trigger allows manually running workflow | |
workflow_dispatch: | |
branches: | |
- master | |
# Enable only running 1 workflow at a time, cancelling previous in progress | |
# This prevents race-condition between multiple workflows being triggered | |
# We only need one to run at a time, and it should be from the most recent trigger/commit | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
policy_list: | |
name: "Update Active Policy List" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
# ruby-version: 2.4.1 # Not needed with a .ruby-version file | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: Generate Active Policy List | |
shell: bash -l {0} # https://github.com/actions/virtual-environments/issues/4 | |
run: | | |
bundle install --without documentation --path bundle | |
bundle exec rake generate_policy_list | |
cp dist/active-policy-list.json data/active_policy_list/active_policy_list.json | |
env: | |
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
commit-message: "Update active policy list" | |
title: "Update Active Policy List" | |
body: "Update Active Policy List from GitHub Actions Workflow [${{ github.workflow }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" | |
branch: "task/update-active-policy-list" | |
add-paths: "data/active_policy_list/active_policy_list.json" | |
delete-branch: true | |
labels: "automation, data" | |
- name: Check outputs | |
if: ${{ steps.cpr.outputs.pull-request-number }} | |
run: | | |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | |
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |