Skip to content

Check Saleor release and update types #262

Check Saleor release and update types

Check Saleor release and update types #262

Workflow file for this run

name: Check Saleor release and update types
on:
workflow_dispatch:
schedule:
- cron: "0 18 * * 1-5" # workdays at 18:00
jobs:
check_saleor_release:
name: Check Saleor release and update types
runs-on: ubuntu-latest
steps:
- name: Get latest release info
id: release
run: |
echo "Fetching latest release info..."
latest_release=$(curl -s https://api.github.com/repos/saleor/saleor/releases/latest)
echo "tag=$(echo $latest_release | jq -r '.tag_name')" >> "$GITHUB_OUTPUT"
echo "schema_url=$(echo $latest_release | jq -r '.assets[] | select(.name == "schema.graphql") | .url')" >> "$GITHUB_OUTPUT"
echo "has_schema=$(echo $latest_release | jq -e '.assets[] | select(.name == "schema.graphql") | length > 0')" >> "$GITHUB_OUTPUT"
- name: Check for schema.graphql in the latest Saleor release
run: |
if [[ "${{ steps.release.outputs.has_schema }}" == "true" ]]; then
echo "schema.graphql is attached to the ${{ steps.release.outputs.tag }} release, updating..."
else
echo "schema.graphql is not attached to the ${{ steps.release.outputs.tag }} release, exiting..."
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v4
- name: Download schema.graphql
run: |
curl --output schema.graphql \
--url ${{ steps.release.outputs.schema_url }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header "Accept: application/octet-stream" \
--location
- name: Get PNPM version from package.json
id: pnpm-version
run: echo "pnpm_version=$(cat package.json | jq '.engines.pnpm' | sed -E 's/[^0-9.]//g')" >> $GITHUB_OUTPUT
- name: Install PNPM
uses: pnpm/action-setup@v2
with:
version: ${{ steps.pnpm-version.outputs.pnpm_version }}
- uses: actions/setup-node@v3
with:
node-version-file: package.json
cache: "pnpm"
- name: Install dependencies
run: pnpm --version && pnpm install --frozen-lockfile
- name: Run `pnpm generate`
id: generate-schema-from-file
run: pnpm generate
- name: Remove schema
run: rm -f schema.graphql
- name: Show changed files
run: git status
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
branch: update-schema
commit-message: "Update schema to Saleor ${{ steps.release.outputs.tag }}"
title: "Update schema to Saleor ${{ steps.release.outputs.tag }}"
body: |
Pull request auto-generated by bot
labels: |
:robot: bot