Sync Labels #129
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: Sync Labels | |
on: | |
label: | |
types: [created, edited, deleted] | |
push: | |
paths: | |
- .github/workflows/sync-labels.yml | |
branches: | |
- main | |
jobs: | |
label-sync: | |
name: Install & Run | |
runs-on: ubuntu-latest | |
env: | |
# Personal access token for `hyphacoop-bot` with `repo` permission | |
# See: https://github.com/hyphacoop/organizing/settings/secrets/new | |
# GITHUB_API_TOKEN secret could not be used variable renamed to API_TOKEN_HYPHACOOP_BOT | |
GITHUB_API_TOKEN: ${{ secrets.API_TOKEN_HYPHACOOP_BOT }} | |
LABEL_REPO_SOURCE: hyphacoop/organizing | |
# Note: `hyphacoop-bot` user must also be given `write` access to repos via @hyphacoop/robots team. | |
# See: https://github.com/orgs/hyphacoop/teams/robots/repositories | |
# See: https://yaml-multiline.info/ | |
LABEL_REPO_TARGETS: >- | |
hyphacoop/demo-repo | |
hyphacoop/handbook | |
hyphacoop/hypha.coop | |
hyphacoop/hyphacoop-chatbot | |
hyphacoop/meshmedia | |
hyphacoop/organizing-private | |
hyphacoop/remote | |
hyphacoop/spreadsheet2shortlinks | |
hyphacoop/test-private | |
hyphacoop/vision.hypha.coop | |
hyphacoop/worker-coop-scripts | |
# Posts comment to https://github.com/hyphacoop/organizing/issues/145 | |
NOTIFIED_REPO: hyphacoop/organizing | |
NOTIFIED_ISSUE: 145 | |
EXPLAINING_LINK: https://github.com/hyphacoop/organizing/pull/146 | |
steps: | |
- name: Setup PHP | |
# See: https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@master | |
with: | |
php-version: '7.3' | |
# See: https://github.com/vanilla/github-sync | |
- name: Sync labels | |
run: | | |
composer --quiet require vanilla/github-sync | |
for target in $LABEL_REPO_TARGETS; do | |
# NOTE: "prune" ensures that missing tags will be culled from target repo, but ONLY if they are unused. | |
./vendor/bin/github-sync labels --from $LABEL_REPO_SOURCE --to $target --delete prune | |
done | |
- name: Notify issue | |
run: | | |
cat <<EOF > comment-payload.json | |
{"body": "Labels have been synced! About: $EXPLAINING_LINK\n\n<sub>:scroll: Technical log: https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA/checks#step:3:15</sub>"} | |
EOF | |
cat comment-payload.json | |
curl --request POST \ | |
--data @comment-payload.json \ | |
--header "Authorization: token $GITHUB_API_TOKEN" \ | |
"https://api.github.com/repos/${NOTIFIED_REPO}/issues/${NOTIFIED_ISSUE}/comments" |