-
Notifications
You must be signed in to change notification settings - Fork 2
76 lines (67 loc) · 2.53 KB
/
build_downgraded.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
## builds the content of https://github.com/alamirault/fftt-api
## inspiration from https://github.com/rectorphp/rector-src/blob/main/.github/workflows/build_scoped_rector.yaml
name: Build production
on:
push:
branches:
- main
tags:
- '*'
env:
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION: "dev-main"
BUILD_REPOSITORY_NAME: "built"
jobs:
build:
name: Downgrade and publish to fftt-api
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Downgrade code for production (to PHP 7.1)
run: |
composer install
bin/rector process
- name: Build project for production
run: |
mkdir $BUILD_REPOSITORY_NAME
cp -rT build/target-repository $BUILD_REPOSITORY_NAME
cp -R src $BUILD_REPOSITORY_NAME
# clone remote repository, so we can push it
-
uses: "actions/checkout@v3"
with:
repository: alamirault/fftt-api
path: remote-repository
token: ${{ secrets.ACCESS_TOKEN_FFTT_API }}
- name: Clean git repository and put new built files
run: |
mv remote-repository/.git .fftt-api-git
rm -rf remote-repository/*
mv .fftt-api-git remote-repository/.git
cp -rT $BUILD_REPOSITORY_NAME remote-repository
- name: Setup git author
working-directory: remote-repository
run: |
git config user.email "lamiraultantoine@gmail.com"
git config user.name "Antoine Lamirault"
-
name: "Get Git log"
id: git-log
run: echo ::set-output name=log::$(git log ${{ github.event.before }}..${{ github.event.after }} --reverse --pretty='%H %s' | sed -e 's/^/https:\/\/github.com\/alamirault\/fftt-api-src\/commit\//')
# A publish it to remote repository without tag
-
name: "Commit Prefixed - main"
working-directory: remote-repository
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
git add --all
git commit -m "Updated FFTTApi to commit ${{ github.event.after }}" -m "${{ steps.git-log.outputs.log }}"
git push --quiet origin main
# B publish it to remote repository with tag
-
name: "Commit Prefixed - tag"
working-directory: remote-repository
if: "startsWith(github.ref, 'refs/tags/')"
run: |
git tag ${GITHUB_REF#refs/tags/} -m "${GITHUB_REF#refs/tags/}"
git push --quiet origin ${GITHUB_REF#refs/tags/}