Synchronize team members in the .env file #339
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@d632683dd7b4114ad314bca15554477dd762a938 | |
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 |