Skip to content

check merged condition #23

check merged condition

check merged condition #23

name: Update authorized users
on:
workflow_dispatch:
pull_request_target:
types:
- closed
branches:
- main
paths:
- 'model-metadata/*.yaml'
jobs:
update-users-list:
if: github.event.pull_request.merged == true
runs-on: ubuntu-22.04
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
install-r: false
use-public-rspm: true
- name: Install dependencies
run: |
install.packages(c("yaml", "purrr"))
shell: Rscript {0}
- name: generate users list
run: |
Rscript src/code/get_authorized_users.r
- name: Check for Changes
id: check_diff
run: |
git diff --exit-code src/code/authorized_users.txt || echo "changed=true" >> $GITHUB_ENV
- name: Commit changes
if: env.changed == 'true'
uses: EndBug/add-and-commit@v9
with:
message: "Update authorized users"
default_author: github_actions
push: true
new_branch: update-authorized-users
- name: Create pull request
if: env.changed == 'true'
run: |
gh pr create --base main --head update-authorized-users --title "Update authorized users" --body "This PR updates the authorized users list based on the latest metadata."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}