From 02c8ce1c2e95155bad9b6a402c582b8ed618d176 Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:03:33 +0200 Subject: [PATCH 1/2] docs: implement schema for GitHub workflows --- .github/workflows/cd.yml | 1 + .github/workflows/check.yml | 1 + .github/workflows/ci.yml | 1 + .github/workflows/cleanup.yml | 1 + .github/workflows/deploy.yml | 1 + .github/workflows/security.yml | 1 + 6 files changed, 6 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 8c818644f..6677f6811 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json name: CD on: diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6426063c0..090b0e579 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json name: Check on: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba6617c25..1c12f4184 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json name: CI on: diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index d1e89521c..d72b2fe26 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json name: Cleanup on: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 744011b64..acf094b86 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json name: Deploy on: diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 46d89deed..1679b68c8 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json name: Docker Scan on: From a08886d0a148a89aabae0c10b9bd64a48e28586b Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:11:45 +0200 Subject: [PATCH 2/2] chore: add Upgrade GitHub workflow --- .github/workflows/upgrade-api-platform.yml | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/upgrade-api-platform.yml diff --git a/.github/workflows/upgrade-api-platform.yml b/.github/workflows/upgrade-api-platform.yml new file mode 100644 index 000000000..5f09ef974 --- /dev/null +++ b/.github/workflows/upgrade-api-platform.yml @@ -0,0 +1,72 @@ +# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json +name: Upgrade API Platform + +on: + workflow_dispatch: ~ + +jobs: + upgrade: + name: Upgrade + if: ${{ github.repository == 'api-platform/demo' }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Setup PHP with Composer + uses: shivammathur/setup-php@v2 + with: + tools: composer + - + name: Get Composer Cache Directory + id: composer-cache + working-directory: api + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - + name: Cache Dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + - + name: Update API Platform Dependencies + working-directory: api + run: composer update "api-platform/*" --no-install --no-scripts + - + name: Calculate Diff + working-directory: api + id: diff + run: | + echo "from-version=$(git diff composer.lock | grep -m 1 "api-platform/*" -A 2 | grep -oP '^-\s*"version": "v(.*)",' | sed -e 's/^-\s*"version": "v\(.*\)",$/\1/')" >> $GITHUB_OUTPUT + echo "to-version=$(git diff composer.lock | grep -m 1 "api-platform/*" -A 2 | grep -oP '^\+\s*"version": "v(.*)",' | sed -e 's/^\+\s*"version": "v\(.*\)",$/\1/')" >> $GITHUB_OUTPUT + - + name: Update API version + if: steps.diff.outputs.to-version != '' + run: | + sed -i "s/version: .*/version: ${{ steps.diff.outputs.to-version }}/g" api/config/packages/api_platform.yaml + sed -i "s/^version: .*/version: ${{ steps.diff.outputs.to-version }}/g" helm/api-platform/Chart.yaml + sed -i "s/^appVersion: .*/appVersion: ${{ steps.diff.outputs.to-version }}/g" helm/api-platform/Chart.yaml + - + name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + if: steps.diff.outputs.to-version != '' + with: + token: ${{ secrets.API_PLATFORM_DEMO_PR_TOKEN }} + branch: release/api-platform-${{ steps.diff.outputs.to-version }} + base: ${{ github.event.repository.default_branch }} + commit-message: "chore: upgrade API Platform to ${{ steps.diff.outputs.to-version }}" + committer: "${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>" + author: "${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>" + title: "chore: upgrade API Platform to ${{ steps.diff.outputs.to-version }}" + body: "See https://github.com/api-platform/core/releases/tag/v${{ steps.diff.outputs.to-version }}." + labels: dependencies + assignees: vincentchalamon + add-paths: | + api/composer.* + api/config/packages/api_platform.yaml + helm/api-platform/Chart.yaml