Skip to content

Password-related JSON Files #752

Password-related JSON Files

Password-related JSON Files #752

name: Password-related JSON Files
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *' # every morning at 3am UTC
jobs:
update:
name: Get latest password-related json files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Get latest files
run: cd packages/password && npm run files:update
- name: Check for changes
id: changes
run: |
filesChanged=$(sh ./scripts/check-for-changes.sh)
if [ -z "$filesChanged" ]; then hasChanged="false"; else hasChanged="true"; fi
echo "hasChanged=$hasChanged" >> "$GITHUB_OUTPUT"
shell: bash {0}
- name: Get current date
id: date
run: |
echo "currentDate=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"
- name: Check for existing PR
if: ${{ steps.changes.outputs.hasChanged == 'true' }}
id: existing_pr
run: |
pr_numbers=$(gh pr list --state open --head automated/update-password-json-files --json number,createdAt --jq 'sort_by(.createdAt) | reverse | .[].number')
if [ -n "$pr_numbers" ]; then
pr_count=$(echo "$pr_numbers" | wc -l)
if [ "$pr_count" -gt 1 ]; then
echo "Warning: Found $pr_count existing PRs. Using the most recent one."
fi
most_recent_pr=$(echo "$pr_numbers" | head -n1)
echo "existingPR=$most_recent_pr" >> "$GITHUB_OUTPUT"
echo "hasExistingPR=true" >> "$GITHUB_OUTPUT"
else
echo "hasExistingPR=false" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}
- name: Update build if needed
if: ${{ steps.changes.outputs.hasChanged == 'true' }}
run: |
npm ci
npm run build
- name: Create or update PR for updated files
if: ${{ steps.changes.outputs.hasChanged == 'true' }}
uses: peter-evans/create-pull-request@b3a2c5d525a1eb75e75c781e45a1bf3bfc23bdc6
with:
add-paths: |
packages/password/rules.json
packages/password/shared-credentials.json
dist/
swift-package/
commit-message: Update password-related json files
branch: automated/update-password-json-files
title: 'Update password-related json files'
body: 'Updating password-related json files from remote source, last updated on ${{steps.date.outputs.currentDate}}'
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}