Check outdated build db #195
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: Check outdated build db | |
on: | |
workflow_dispatch: | |
inputs: | |
create_pr: | |
type: boolean | |
required: false | |
default: false | |
send_to_slack: | |
type: boolean | |
required: false | |
default: false | |
schedule: | |
- cron: '32 5 * * 3' | |
pull_request: | |
jobs: | |
compare_files: | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Build db | |
run: | | |
python3 scripts/entrypoint.py create_app_list --full_output_file out.json --access_token ${{ secrets.GH_ACCESS_TOKEN }} | |
- name: Upload file | |
uses: actions/upload-artifact@v3 | |
with: | |
name: out.json | |
path: out.json | |
if-no-files-found: error | |
- name: Compare Files | |
run: | | |
# Compare two files using diff | |
diff -q out.json input_files/input.json | |
# Store the exit code of the diff command | |
DIFF_EXIT_CODE=$? | |
# If exit code is 0, files are the same; if not, they are different | |
if [ $DIFF_EXIT_CODE -ne 0 ]; then | |
echo "Files are different!" | |
exit 1 # Fail the workflow | |
else | |
echo "Files are the same!" | |
fi | |
- name: Echo GHA url | |
if: ${{ failure() && (github.event_name == 'schedule' || inputs.send_to_slack == true) }} | |
run: echo "url"=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_ENV | |
- name: Send custom JSON data to Slack workflow | |
if: ${{ failure() && (github.event_name == 'schedule' || inputs.send_to_slack == true) }} | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
payload-file-path: slack.json | |
payload: | | |
{ | |
"title": "Check input list", | |
"status": ":red-cross: Fail", | |
"status_detail": ":alert: Please update input file ! ", | |
"url": "${{ env.url }}" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
- name: Commit and push changes | |
if: ${{ failure() && (github.event_name == 'schedule' || inputs.create_pr == true) }} | |
run: | | |
git config --global user.name "Ledger App Tester Bot" | |
git config --global user.email "[email protected]" | |
git checkout -b update-input | |
cp out.json input_files/input.json | |
git add input_files/input.json | |
git commit -m "[auto] Update input file" | |
git push --set-upstream origin update-input --force | |
- name: Create Pull Request | |
if: ${{ failure() && (github.event_name == 'schedule' || inputs.create_pr == true) }} | |
run: | | |
apk add github-cli | |
gh pr create --base "develop" --head "update-input" --title "[BOT] Update input file" --body "Input file has changed ! Please review changes !" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |