Update Stdlib Dependency Graph #1271
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 Stdlib Dependency Graph | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 3,15 * * *' # Run everyday at 8.30 AM and 8.30 PM on LK time | |
push: | |
branches: | |
- main | |
paths: | |
- 'release/resources/module_list.json' | |
jobs: | |
dependency_graph: | |
name: Update the Ballerina Library Dependency Graph | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
- name: Configure Git User | |
run: | | |
git config --global user.name ${{ secrets.BALLERINA_BOT_USERNAME }} | |
git config --global user.email ${{ secrets.BALLERINA_BOT_EMAIL }} | |
git pull | |
git checkout -b update-dependency-graph | |
- name: Update the Dependencies and Generate the Dashboard | |
uses: ballerina-platform/ballerina-action@2201.8.0 | |
with: | |
args: | |
run | |
env: | |
WORKING_DIR: ./dashboard | |
BALLERINA_BOT_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} | |
- name: Commit Files | |
id: commitFiles | |
run: | | |
git add -u | |
git reset -- dashboard/Dependencies.toml | |
if git diff-index --quiet HEAD --; | |
then | |
printf "::set-output name=hasChanged::false" | |
else | |
git commit -m "[AUTOMATED] Update the dependency graph and the dashboard" | |
printf "::set-output name=hasChanged::true" | |
fi | |
- name: Push Results | |
if: ${{ steps.commitFiles.outputs.hasChanged == 'true' }} | |
run: git push origin "update-dependency-graph" | |
env: | |
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} | |
- name: Create Pull Request to Update the Dashboard | |
id: createPR | |
if: ${{ steps.commitFiles.outputs.hasChanged == 'true' }} | |
run: printf "::set-output name=prUrl::$(gh pr create --title "[Automated] Update the Ballerina Library Dashboard" --body "Updating the Ballerina library dashboard with latest changes")" | |
env: | |
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} | |
- name: Approve PR | |
if: ${{ steps.commitFiles.outputs.hasChanged == 'true' }} | |
run: | | |
sleep 5 | |
gh pr review --approve ${{ steps.createPR.outputs.prUrl }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.BALLERINA_REVIEWER_BOT_TOKEN }} | |
- name: Merge PR | |
if: ${{ steps.commitFiles.outputs.hasChanged == 'true' }} | |
run: | | |
checkCount="0" | |
while [ "$checkCount" != "1" ] | |
do | |
sleep 20 | |
checkCount=$(gh pr status --jq '[.currentBranch .statusCheckRollup[] | select((.conclusion=="SUCCESS") and ((.name=="Build on Ubuntu")))] | length' --json statusCheckRollup) | |
failedCount=$(gh pr status --jq '[.currentBranch .statusCheckRollup[] | select((.conclusion=="FAILURE") and ((.name=="Build on Ubuntu")))] | length' --json statusCheckRollup) | |
if [[ "$failedCount" != "0" ]] | |
then | |
echo "PR Build has Failed" | |
exit 1 | |
fi | |
done | |
sleep 20 | |
gh pr merge --merge --delete-branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} |