name: Compare Pricing Data on: schedule: - cron: '0 18 * * *' permissions: contents: read jobs: compare-usd: runs-on: ubuntu-latest outputs: exit_code: ${{ steps.compare.outputs.exit_code }} steps: - uses: actions/checkout@v6.0.2 - name: Install Go uses: actions/setup-go@v6 with: go-version: 'stable' - name: Go Mod cache uses: actions/cache@v5 with: path: | ~/.cache/go-build ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - name: Compare USD pricing data id: compare working-directory: modules/pricing/public/cmd env: GCP_API_KEY: ${{ secrets.GCP_API_KEY }} # Capture the exit code before the shell exits so downstream steps can # distinguish drift (2) from a generation/infra error (1). run: | set +e go run . --currency USD --compare CODE=$? echo "exit_code=$CODE" >> $GITHUB_OUTPUT exit $CODE compare-cny: runs-on: ubuntu-latest outputs: exit_code: ${{ steps.compare.outputs.exit_code }} steps: - uses: actions/checkout@v6.0.2 - name: Install Go uses: actions/setup-go@v6 with: go-version: 'stable' - name: Go Mod cache uses: actions/cache@v5 with: path: | ~/.cache/go-build ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - name: Compare CNY pricing data id: compare working-directory: modules/pricing/public/cmd # CNY does not use GCP so no API key needed run: | set +e go run . --currency CNY --compare CODE=$? echo "exit_code=$CODE" >> $GITHUB_OUTPUT exit $CODE notify-drift: runs-on: ubuntu-latest needs: [compare-usd, compare-cny] if: | always() && (needs.compare-usd.outputs.exit_code == '2' || needs.compare-cny.outputs.exit_code == '2') steps: - name: Notify Slack — pricing drift uses: slackapi/slack-github-action@v2 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} payload: | channel: ${{ secrets.SLACK_PRICING_CHANNEL_ID }} text: ":warning: Pricing data drift detected :warning:" blocks: - type: section text: type: mrkdwn text: ":warning: *Pricing data drift detected*\nUSD: ${{ needs.compare-usd.outputs.exit_code == '2' && 'drifted :x:' || 'ok :white_check_mark:' }} | CNY: ${{ needs.compare-cny.outputs.exit_code == '2' && 'drifted :x:' || 'ok :white_check_mark:' }}\nThe live cloud provider pricing no longer matches the committed .\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>"