Update Resource Schema #107
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: Update Resource Schema | |
env: | |
SOURCE_AWS_REPO: pulumi/pulumi-aws | |
SOURCE_GCP_REPO: pulumi/pulumi-gcp | |
USERNAME: ${{ github.actor }} | |
PATH_AWS_SOURCE_CHECKOUT: upstream_pulumi_aws_repo | |
PATH_GCP_SOURCE_CHECKOUT: upstream_pulumi_gcp_repo | |
PATH_OUR_REPO_CHECKOUT: our_codegen_repo | |
TARGET_AWS_FILE: "provider/cmd/pulumi-resource-aws/schema.json" | |
TARGET_GCP_FILE: "provider/cmd/pulumi-resource-gcp/schema.json" | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
permissions: write-all | |
jobs: | |
UpdateSchemaFiles: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout pulumi/pulumi-aws repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ env.SOURCE_AWS_REPO }} | |
path: ${{ env.PATH_AWS_SOURCE_CHECKOUT }} | |
- name: Checkout pulumi/pulumi-gcp repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ env.SOURCE_GCP_REPO }} | |
path: ${{ env.PATH_GCP_SOURCE_CHECKOUT }} | |
- name: Checkout Our Codegen repo | |
uses: actions/checkout@v4 | |
with: | |
path: ${{ env.PATH_OUR_REPO_CHECKOUT }} | |
- name: Check if the AWS schema file was changed | |
run: | | |
cd $PATH_AWS_SOURCE_CHECKOUT | |
if [[ $(git log --since='1 day ago' ${{ env.TARGET_AWS_FILE }} | wc -w) -gt 0 ]]; then | |
echo 'We have changes' | |
cd .. | |
cp $PATH_AWS_SOURCE_CHECKOUT/$TARGET_AWS_FILE $PATH_OUR_REPO_CHECKOUT/resourceSchema/schema_aws.json | |
echo "MergeChanges=true" >> $GITHUB_ENV | |
else | |
echo 'We have no AWS schema changes' | |
fi | |
- name: Check if the GCP schema file was changed | |
run: | | |
cd $PATH_GCP_SOURCE_CHECKOUT | |
if [[ $(git log --since='1 day ago' ${{ env.TARGET_GCP_FILE }} | wc -w) -gt 0 ]]; then | |
echo 'We have changes' | |
cd .. | |
cp $PATH_GCP_SOURCE_CHECKOUT/$TARGET_GCP_FILE $PATH_OUR_REPO_CHECKOUT/resourceSchema/schema_gcp.json | |
echo "MergeChanges=true" >> $GITHUB_ENV | |
else | |
echo 'We have no GCP schema changes' | |
fi | |
- name: Update GCP schema file | |
if: env.MergeChanges == 'true' | |
run: | | |
cd $PATH_OUR_REPO_CHECKOUT | |
git add . | |
if [[ $(git diff --staged --name-only|wc -l) -gt 0 ]]; then | |
echo "We do have changes between the copies, we are committing the changes" | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" | |
git commit -m "Updated Schema files" | |
git push -f origin main | |
else | |
echo "We have no changes between the copies, exiting" | |
fi | |
cd .. | |