Update names #199
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 names | |
on: | |
schedule: | |
# Run at 12 every tuesday | |
- cron: '0 12 * * 2' | |
workflow_dispatch: | |
jobs: | |
update: | |
name: Update names | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: is_IS.UTF-8 | |
run: | | |
sudo locale-gen is_IS.UTF-8 | |
sudo update-locale LANG=is_IS.UTF-8 | |
- name: Install dependencies | |
run: pip install aiohttp | |
- name: Update allowed names | |
run: python update_allowed_names.py | |
- name: Create PR body | |
id: get-pr-body | |
run: | | |
function gather() { git diff $1 | grep -E '^\+\s+"\w+",' | sed -E 's/\+\s+"(\w+)",/\1/g'; } | |
export MALE_NAMES=$(gather backend/server/names/male.json ) | |
export FEMALE_NAMES=$(gather backend/server/names/female.json ) | |
body=$(cat update-names-pr-body.txt | envsubst) | |
body="${body//'%'/'%25'}" | |
body="${body//$'\n'/'%0A'}" | |
body="${body//$'\r'/'%0D'}" | |
echo ::set-output name=body::$body | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
commit-message: Update allowed names from Hagstofa | |
delete-branch: true | |
branch-suffix: timestamp | |
title: Update allowed names from Hagstofa | |
body: ${{ steps.get-pr-body.outputs.body }} | |
reviewers: sindrig | |
labels: automerge |