Skip to content

Check for Community Package Updates #1930

Check for Community Package Updates

Check for Community Package Updates #1930

name: Check for Community Package Updates
on:
workflow_dispatch:
schedule:
# Every day at 5:30 and 17:30 UTC.
- cron: '30 5,17 * * *'
env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
jobs:
generate-packages-list:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(python generate_package_list.py)" >> $GITHUB_OUTPUT
working-directory: community-packages
- name: List open pull requests
id: list
run: source ./scripts/common.sh && echo "titles=$(list_pull_requests)" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
prs: ${{ steps.list.outputs.titles }}
check-for-package-update:
name: ${{ matrix.repoSlug }}
needs: generate-packages-list
runs-on: ubuntu-latest
strategy:
fail-fast: false
# GitHub recommends only issuing 1 API request per second, and never
# concurrently. For more information, see:
# https://docs.github.com/en/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits
max-parallel: 1
matrix: ${{fromJson(needs.generate-packages-list.outputs.matrix)}}
steps:
- name: Get provider short name
id: regex-prov
run: |
if [[ "$REPO_SLUG" =~ (\/[^-]*-)(.*?$) ]]; then
echo "group2=${BASH_REMATCH[2]}" >> $GITHUB_OUTPUT
else
echo "Regex pattern match error."
exit 1
fi
env:
REPO_SLUG: ${{ matrix.repoSlug }}
- name: Check if there is already an open PR
if: contains(needs.generate-packages-list.outputs.prs, steps.regex-prov.outputs.group2 )
id: skip-run
run: echo "skip=1" >> $GITHUB_OUTPUT
- name: Check out registry repo
if: steps.skip-run.outputs.skip != 1
uses: actions/checkout@v4
- name: Sleep to prevent hitting secondary rate limits
if: steps.skip-run.outputs.skip != 1
run: sleep 1
- name: Check for a new version
if: steps.skip-run.outputs.skip != 1
id: version
run: |
echo 'PROVIDER_VERSION<<EOF' >> $GITHUB_ENV
go build -C tools/resourcedocsgen
./tools/resourcedocsgen/resourcedocsgen pkgversion --repoSlug ${{ matrix.repoSlug }} \
>> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
# This will only be populated if the registry version does not match the latest provider version.
- name: Display new version
if: env.PROVIDER_VERSION
run: echo ${{ env.PROVIDER_VERSION}}
# We only need to run the following steps if resourcedocsgen found a newer version of the community provider.
- name: Generate Package Metadata
if: env.PROVIDER_VERSION
run: |
go build -C tools/resourcedocsgen
./tools/resourcedocsgen/resourcedocsgen \
metadata --repoSlug ${{ matrix.repoSlug }} --schemaFile ${{ matrix.schemaFile }} \
--version ${{ env.PROVIDER_VERSION }}
- name: Create registry PR
if: env.PROVIDER_VERSION
uses: ./.github/actions/new-provider-version-pr
with:
github_token: ${{ secrets.PULUMI_BOT_TOKEN }}
provider_short_name: ${{ steps.regex-prov.outputs.group2 }}
provider_version: ${{ env.PROVIDER_VERSION }}
notify:
if: failure()
name: Send slack notification
runs-on: ubuntu-latest
needs: [check-for-package-update, generate-packages-list]
steps:
- name: Slack Notification
uses: docker://sholung/action-slack-notify:v2.3.0
env:
SLACK_CHANNEL: registry-ops
SLACK_COLOR: "#F54242"
SLACK_MESSAGE: "generate package metadata failure in pulumi/registry repo :meow_sad:"
SLACK_USERNAME: registrybot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON: https://www.pulumi.com/logos/brand/avatar-on-white.png