Skip to content

set-new-golden

set-new-golden #26

name: Create draft PR for updated rules
on:
repository_dispatch:
types:
- set-new-golden
jobs:
update:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Check out repository code recursively
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Git prep
run: |
git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"
git fetch
git checkout "origin/pr/${{ github.event.client_payload.branch }}"
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Python Packages
run: |
pip install firebase-admin
- name: Execute Python Script Update
env:
CREDS_FILE: ${{ secrets.CREDS_FILE }}
API_BASE_URL: ${{ secrets.API_BASE_URL }}
run: |
echo ${{ github.event_name }}
echo ${{ github.event.client_payload.type }}
if [[ "${{ github.event_name }}" == "repository_dispatch" && "${{ github.event.client_payload.type }}" == "overwrite" ]]; then
python flow/util/updateRules.py --keyFile "${CREDS_FILE}" --apiURL ${API_BASE_URL} --commitSHA ${{ github.event.client_payload.commitsha }} --overwrite
else
python flow/util/updateRules.py --keyFile "${CREDS_FILE}" --apiURL ${API_BASE_URL} --commitSHA ${{ github.event.client_payload.commitsha }}
fi
- name: Push updated rules
id: remote-update
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
if [ -n "$(git status --porcelain)" ]; then
echo "has_update=true" >> "$GITHUB_OUTPUT"
else
echo "has_update=false" >> "$GITHUB_OUTPUT"
fi
git add .
git commit --signoff -m "flow: update rules based on new golden reference"
- if: "github.event.client_payload.branch != 'master'"
name: update rules pr
id: remote-update-pr
run: |
git push origin "HEAD:refs/pull/${{ github.event.client_payload.branch }}/head"
- if: "steps.remote-update.outputs.has_update == 'true' && github.event.client_payload.branch == 'master'"
name: Create Draft PR
uses: peter-evans/create-pull-request@v5
with:
token: ${{ github.token }}
signoff: true
delete-branch: true
title: "[BOT] Update rules"
reviewers: |
vvbandeira
maliberty
draft: true
branch: bot-update-rules
commit-message: |
[BOT] Update rules