Skip to content

Check for Release

Check for Release #229

name: Check for Release
on:
schedule:
- cron: '0 12 * * *' # Cron expression for 12 PM UTC (6 AM CST)
jobs:
check-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Install Dependencies
run: npm install
- name: Check for Release
id: get-release
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: Snowflake-Labs
repo: terraform-provider-snowflake
excludes: prerelease, draft
- name: Get terraform-cdk-provider-snowflake Version
id: get-version
run: |
version=$(cat src/snowflake_resources/snowflake_provider.ts | grep -oE 'providerVersionConstraint: "[0-9]+\.[0-9]+\.[0-9]+"' | awk -F'"' '{print "v"$2}')
echo "::set-output name=MY_VERSION::$version"
echo $version
shell: bash
- name: Compare Release and Version
id: compare-release-version
run: |
release="${{ steps.get-release.outputs.release }}"
extracted_version="${{ steps.get-version.outputs.MY_VERSION }}"
if [ "$release" = "$extracted_version" ]; then
echo "Versions Match: true"
echo "::set-output name=MATCHES::true"
else
echo "Versions Match: false"
echo "::set-output name=MATCHES::false"
fi
shell: bash
- name: Run Updates for New Release
id: run-updates
env:
PAT: ${{ secrets.EXTERNAL_REPO_PAT }}
USERNAME: ${{ secrets.USERNAME }}
EMAIL: ${{ secrets.EMAIL }}
run: |
match="${{ steps.compare-release-version.outputs.MATCHES }}"
if [ "$match" == 'true' ]; then
echo "terraform-cdk-snowflake-provider is already up to date!"
else
node main.js
git add .
version="${{ steps.get-release.outputs.release }}"
git config user.name "$USERNAME"
git config user.email "$EMAIL"
git commit -m "Update Triggered by GitHub Actions Workflow for New Release $version"
git remote set-url origin https://[email protected]/joshcazalas/terraform-cdk-provider-snowflake.git
git push origin main
fi
shell: bash