Skip to content

Commit a021e6d

Browse files
authored
Prepare push repository logic to anywherephp/jack (#38)
* prepare push repository logic * drop --ansi from swiss-knife check-commented-code, no longer supported
1 parent 3bd8de2 commit a021e6d

6 files changed

Lines changed: 77 additions & 24 deletions

File tree

.github/workflows/code_analysis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
-
3636
name: "Commented Code"
37-
run: vendor/bin/swiss-knife check-commented-code src tests --ansi
37+
run: vendor/bin/swiss-knife check-commented-code src tests
3838

3939
-
4040
name: 'Jack: Open Versions'

.github/workflows/downgraded_release.yaml

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ name: Downgraded Release
22

33
on:
44
push:
5+
branches:
6+
- main
57
tags:
6-
# avoid infinite looping, skip tags that ends with ".74"
7-
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches
88
- '*'
99

1010
jobs:
1111
downgrade_release:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: "actions/checkout@v3"
15+
- uses: "actions/checkout@v5"
1616
with:
17-
token: ${{ secrets.WORKFLOWS_TOKEN }}
17+
token: ${{ secrets.WORKFLOWS_TOKEN || github.token }}
1818

1919
-
2020
uses: "shivammathur/setup-php@v2"
@@ -32,35 +32,65 @@ jobs:
3232
- run: mkdir rector-local
3333
- run: composer require rector/rector --working-dir rector-local --ansi
3434

35-
# downgrade to PHP 7.4
35+
# downgrade to PHP 7.2
3636
- run: rector-local/vendor/bin/rector process bin src vendor --config build/rector-downgrade-php.php --ansi
3737

3838
# clear the dev files
39-
- run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig
39+
- run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig composer.lock composer-dependency-analyser.php
4040

4141
# prefix and scope
4242
- run: sh prefix-code.sh
4343

44-
# copy PHP 7.4 composer + workflows
44+
# remove the original .github, to fully override it with the target repository one below
45+
- run: rm -rf .github
46+
47+
# copy PHP 7.2 composer + workflows
4548
- run: cp -r build/target-repository/. .
4649

47-
# clear the dev files
50+
# clear the build files
4851
- run: rm -rf build prefix-code.sh full-tool-build.sh scoper.php rector.php php-scoper.phar rector-local
4952

53+
# clone the remote repository, so we can commit on top of its history and push without --force
54+
# inspired by https://github.com/easy-coding-standard/ecs-src/blob/main/.github/workflows/buid_release.yaml
55+
-
56+
uses: "actions/checkout@v5"
57+
with:
58+
repository: anywherephp/jack
59+
path: remote-repository
60+
token: ${{ secrets.WORKFLOWS_TOKEN }}
61+
62+
# remove remote files, to avoid piling up dead code in remote repository
63+
# the remote .gitignore must go too, as it ignores the /vendor that is shipped in this scoped build
64+
- run: rm -rf remote-repository/bin remote-repository/src remote-repository/vendor remote-repository/docs remote-repository/.github remote-repository/.gitignore
65+
66+
# copy the downgraded code to the remote repository
67+
- run: rsync -a --exclude .git --exclude remote-repository ./ remote-repository/
68+
5069
# setup git user
5170
-
71+
working-directory: remote-repository
5272
run: |
53-
git config user.email "action@github.com"
54-
git config user.name "GitHub Action"
55-
# publish to the same repository with a new tag
56-
# see https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same-repository/
73+
git config user.email "tomas@getrector.org"
74+
git config user.name "rector-bot"
75+
76+
# publish to remote repository without tag
5777
-
58-
name: "Tag Downgraded Code"
78+
name: "Push Downgraded Code - branch"
79+
working-directory: remote-repository
80+
if: "!startsWith(github.ref, 'refs/tags/')"
5981
run: |
60-
# separate a "git add" to add untracked (new) files too
6182
git add --all
62-
git commit -m "release PHP 7.2 downgraded"
83+
git commit -m "Updated Jack to commit ${{ github.event.after }}"
84+
git push --quiet origin main
6385
64-
# force push tag, so there is only 1 version
65-
git tag "${GITHUB_REF#refs/tags/}" --force
66-
git push origin "${GITHUB_REF#refs/tags/}" --force
86+
# publish to remote repository with tag
87+
-
88+
name: "Push Downgraded Code - tag"
89+
working-directory: remote-repository
90+
if: "startsWith(github.ref, 'refs/tags/')"
91+
run: |
92+
git add --all
93+
git commit --allow-empty -m "Jack ${GITHUB_REF#refs/tags/}"
94+
git push --quiet origin main
95+
git tag "${GITHUB_REF#refs/tags/}" -m "${GITHUB_REF#refs/tags/}"
96+
git push --quiet origin "${GITHUB_REF#refs/tags/}"

build/target-repository/.github/FUNDING.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Auto Closer PR
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: superbrothers/close-pull-request@v3
12+
with:
13+
# Optional. Post a issue comment just before closing a pull request.
14+
comment: |
15+
Hi, thank you for your contribution.
16+
17+
Unfortunately, this repository is read-only. It's a build of the main repository.
18+
19+
We'd like to kindly ask you to move the contribution there - https://github.com/rectorphp/jack.
20+
21+
We'll check it, review it and give you feed back right way.
22+
23+
Thank you.

build/target-repository/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Jack - Anywhere version
2+
3+
See original repository for more details: https://github.com/rectorphp/jack

build/target-repository/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "rector/jack",
2+
"name": "anywherephp/jack",
33
"description": "Swiss knife in pocket of every upgrade architect",
4-
"license": "MIT",
4+
"license": "proprietary",
55
"require": {
66
"php": ">=7.2"
77
},

0 commit comments

Comments
 (0)