Synchronize team members in the .env file #380
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
# Copyright Broadcom, Inc. All Rights Reserved. | |
# SPDX-License-Identifier: APACHE-2.0 | |
name: 'Synchronize team members in the .env file' | |
on: | |
workflow_dispatch: | |
schedule: | |
# Daily | |
- cron: '0 5 * * *' | |
# Remove all permissions by default. Write actions are done by Bitnami Bot | |
permissions: {} | |
jobs: | |
sync-support-teams: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Repo checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
with: | |
fetch-depth: 1 | |
token: ${{ secrets.BITNAMI_BOT_SUPPORT_TOKEN }} | |
- name: Load .env file | |
uses: xom9ikk/dotenv@ac290ca23a42155a0cba1031d23afa46240116a9 | |
- name: Updating members of the Bitnami team | |
env: | |
# only available to authenticated members of the team's organization. OAuth access tokens require the read:org scope | |
TOKEN: ${{ secrets.BITNAMI_BOT_SUPPORT_TOKEN }} | |
run: | | |
TEAM_MEMBERS=$(curl --request GET \ | |
--url https://api.github.com/orgs/bitnami/teams/developers/members?per_page=100 \ | |
--header "authorization: Bearer ${TOKEN}" \ | |
--header 'content-type: application/json' \ | |
| jq 'sort_by(.login)|map(.login)|join(",")') | |
TEAM_MEMBERS='['${TEAM_MEMBERS//','/'","'}']' | |
if [ $TEAM_MEMBERS != $BITNAMI_TEAM ]; then | |
echo "Replacing $BITNAMI_TEAM for $TEAM_MEMBERS" | |
sed -i "s|BITNAMI_TEAM=.*$|BITNAMI_TEAM='${TEAM_MEMBERS}'|g" .env | |
git config user.name "bitnami-bot" | |
git config user.email "bitnami-bot@vmware.com" | |
git commit -s -m"[bitnami-bot] Updating Bitnami team members" .env | |
git push | |
else | |
echo "BITNAMI_TEAM is updated and nothing should be done" | |
fi |