|
| 1 | +name: Nightly Data Update |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 0 * * *' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + update-data: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Set up Go |
| 22 | + uses: actions/setup-go@v4 |
| 23 | + with: |
| 24 | + go-version: '1.21' |
| 25 | + |
| 26 | + - name: Install golangci-lint |
| 27 | + uses: golangci/golangci-lint-action@v3 |
| 28 | + with: |
| 29 | + version: latest |
| 30 | + |
| 31 | + - name: Run generate command |
| 32 | + run: go run . generate |
| 33 | + env: |
| 34 | + AWSMETA_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + |
| 36 | + - name: Check for changes and commit |
| 37 | + id: git-diff |
| 38 | + run: | |
| 39 | + git config --local user.email "action@github.com" |
| 40 | + git config --local user.name "GitHub Action" |
| 41 | + |
| 42 | + # Only add files that should be updated by the generate command |
| 43 | + git add pkg/data/manifests/ go.mod go.sum |
| 44 | + |
| 45 | + if git diff --cached --quiet; then |
| 46 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 47 | + echo "📊 No changes detected in AWS data" |
| 48 | + else |
| 49 | + current_date=$(date +'%Y-%m-%d') |
| 50 | + cat > commit_message.txt << EOF |
| 51 | + chore(data): ⏳nightly AWS data update ($current_date) |
| 52 | + |
| 53 | + - Updated partition data |
| 54 | + - Updated region data |
| 55 | + - Updated service data |
| 56 | + - Updated go.mod/go.sum if needed |
| 57 | + |
| 58 | + Generated on: $current_date |
| 59 | + EOF |
| 60 | + git commit -F commit_message.txt |
| 61 | + rm commit_message.txt |
| 62 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 63 | + echo "📊 Changes detected in AWS data, committing updates" |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Push changes if any |
| 67 | + if: steps.git-diff.outputs.changed == 'true' |
| 68 | + run: | |
| 69 | + git push origin main |
| 70 | + echo "✅ AWS data updates pushed to main branch" |
| 71 | +
|
| 72 | + - name: Log completion |
| 73 | + run: | |
| 74 | + if [ "${{ steps.git-diff.outputs.changed }}" == "true" ]; then |
| 75 | + echo "🎉 Nightly data update completed successfully" |
| 76 | + echo "📈 Latest AWS service, region, and partition data is now available" |
| 77 | + echo "🔄 Weekly release workflow will create the next version tag" |
| 78 | + else |
| 79 | + echo "✨ No updates needed - AWS data is current" |
| 80 | + fi |
0 commit comments