Skip to content

Commit 70bf82d

Browse files
chore: add Upgrade GitHub workflow (#457)
1 parent fdd0496 commit 70bf82d

File tree

7 files changed

+78
-0
lines changed

7 files changed

+78
-0
lines changed

.github/workflows/cd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
12
name: CD
23

34
on:

.github/workflows/check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
12
name: Check
23

34
on:

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
12
name: CI
23

34
on:

.github/workflows/cleanup.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
12
name: Cleanup
23

34
on:

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
12
name: Deploy
23

34
on:

.github/workflows/security.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
12
name: Docker Scan
23

34
on:
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
2+
name: Upgrade API Platform
3+
4+
on:
5+
workflow_dispatch: ~
6+
7+
jobs:
8+
upgrade:
9+
name: Upgrade
10+
if: ${{ github.repository == 'api-platform/demo' }}
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
steps:
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v4
19+
-
20+
name: Setup PHP with Composer
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
tools: composer
24+
-
25+
name: Get Composer Cache Directory
26+
id: composer-cache
27+
working-directory: api
28+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
29+
-
30+
name: Cache Dependencies
31+
uses: actions/cache@v4
32+
with:
33+
path: ${{ steps.composer-cache.outputs.dir }}
34+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
35+
restore-keys: ${{ runner.os }}-composer-
36+
-
37+
name: Update API Platform Dependencies
38+
working-directory: api
39+
run: composer update "api-platform/*" --no-install --no-scripts
40+
-
41+
name: Calculate Diff
42+
working-directory: api
43+
id: diff
44+
run: |
45+
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
46+
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
47+
-
48+
name: Update API version
49+
if: steps.diff.outputs.to-version != ''
50+
run: |
51+
sed -i "s/version: .*/version: ${{ steps.diff.outputs.to-version }}/g" api/config/packages/api_platform.yaml
52+
sed -i "s/^version: .*/version: ${{ steps.diff.outputs.to-version }}/g" helm/api-platform/Chart.yaml
53+
sed -i "s/^appVersion: .*/appVersion: ${{ steps.diff.outputs.to-version }}/g" helm/api-platform/Chart.yaml
54+
-
55+
name: Create Pull Request
56+
uses: peter-evans/create-pull-request@v7
57+
if: steps.diff.outputs.to-version != ''
58+
with:
59+
token: ${{ secrets.API_PLATFORM_DEMO_PR_TOKEN }}
60+
branch: release/api-platform-${{ steps.diff.outputs.to-version }}
61+
base: ${{ github.event.repository.default_branch }}
62+
commit-message: "chore: upgrade API Platform to ${{ steps.diff.outputs.to-version }}"
63+
committer: "${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>"
64+
author: "${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>"
65+
title: "chore: upgrade API Platform to ${{ steps.diff.outputs.to-version }}"
66+
body: "See https://github.com/api-platform/core/releases/tag/v${{ steps.diff.outputs.to-version }}."
67+
labels: dependencies
68+
assignees: vincentchalamon
69+
add-paths: |
70+
api/composer.*
71+
api/config/packages/api_platform.yaml
72+
helm/api-platform/Chart.yaml

0 commit comments

Comments
 (0)