-
Notifications
You must be signed in to change notification settings - Fork 13
123 lines (115 loc) · 5.48 KB
/
deploy.yml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: "[workflow call] Build & deploy given Mage-OS composer repo"
on:
workflow_call:
inputs:
repo:
description: 'The composer repository url'
required: true
default: 'https://preview-mirror.mage-os.org/'
type: string
entrypoint:
description: 'The Javascript command to use'
required: true
default: 'src/make/mirror.js'
type: string
remote_dir:
description: 'Remote folder where the packages are stored'
required: true
default: '/var/www/preview-mirror.mage-os.org/html/'
type: string
delete:
description: 'Remove remote files that do not exist in the build'
required: false
default: true
type: boolean
mageos_release:
description: 'New Mage-OS version (e.g. 1.0.0)'
required: false
default: ''
type: string
upstream_release:
description: 'Closest Magento Open Source version (e.g. 2.4.6-p2)'
required: false
default: ''
type: string
publish_tag:
description: 'Push new release tag to repos (TODO)'
required: false
default: false
type: boolean
secrets:
SERVER_SSH_KEY:
description: "SSH Key used to upload to the satis server."
required: true
REMOTE_USER:
description: "The system user used to upload to the satis server."
required: true
env:
remote_host: "repo.mage-os.org"
remote_dir: ${{ inputs.remote_dir }}
repo: ${{ inputs.repo }}
entrypoint: ${{ inputs.entrypoint }}
delete_arg: ${{ inputs.delete && '--delete' || '' }}
mageos_release: ${{ inputs.mageos_release }}
mageos_release_arg: ${{ inputs.mageos_release != '' && format('--mageosRelease="{0}"', inputs.mageos_release) || '' }}
upstream_release_arg: ${{ inputs.upstream_release != '' && format('--upstreamRelease="{0}"', inputs.upstream_release) || '' }}
publish_tag: ${{ inputs.publish_tag }}
jobs:
deploy:
runs-on: ubuntu-latest
name: "Deploy ${{ inputs.repo }}"
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: composer:2.7
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- run: curl -L https://github.com/mage-os/php-dependency-list/raw/main/php-classes.phar -o /usr/local/bin/php-classes.phar && chmod +x /usr/local/bin/php-classes.phar
name: "Install PHP source code dependency analyzer and make executable (used by nightly build script for base package)"
# Composer create-project and composer require have limited support for commit hashes, they check composer-plugin-api constraints
# of the specified branch HEAD instead of the specified commit hash.
#- run: composer create-project "composer/satis:dev-main#fafc1c2eca6394235f12f8a3ee4da7fc7c9fc874"
# To work around the limitation, we use: git clone && git install.
#
# The fafc1c2eca6394235f12f8a3ee4da7fc7c9fc874 hash is the last satis commit that supports composer 2.2.x, which is currently required by the
# Magento core dependency laminas/laminas-dependency-plugin
- run: git clone https://github.com/composer/satis.git satis && cd satis && git checkout fafc1c2eca6394235f12f8a3ee4da7fc7c9fc874 && composer install && cd -
name: "Install satis"
- run: npm ci
- run: |
node ${{ env.entrypoint }} --outputDir=build/packages --gitRepoDir=generate-repo/repositories --repoUrl="${{ env.repo }}" \
${{ env.mageos_release_arg }} ${{ env.upstream_release_arg }}
name: "Generate the packages for the composer repo"
- run: node bin/set-satis-homepage-url.js --satisConfig=satis.json --repoUrl="${{ env.repo }}" > /tmp/satis.json
name: "Configure satis repository URL so composer knows where to download packages from"
- run: cat <<< $(jq '."output-dir" = "../build" | .repositories[0].url = "../build/packages"' /tmp/satis.json) > /tmp/satis.json
name: "Tell satis where to find the generated packages"
- run: |
cp mageos.html.twig satis/views/mageos.html.twig
jq -r .version package.json > satis/views/version
name: "Add generator version number to Satis HTML"
- run: cd satis && bin/satis build /tmp/satis.json ../build && cd -
name: "Run satis"
- run: cd satis && node ../bin/set-satis-output-url-prefix.js --satisOutputDir=../build --repoUrl="${{ env.repo }}" && cd -
name: "Fix path to packages in the packages.json satis created"
- uses: easingthemes/ssh-deploy@v4
name: "Rsync over SSH"
env:
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
REMOTE_HOST: ${{ env.remote_host }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ env.remote_dir }}
ARGS: "--verbose --compress --recursive --links --times --omit-dir-times ${{ env.delete_arg }}"
SOURCE: "build/*"
- run: cd generate-repo && tar -cf ../release-build-working-copies-${{ env.mageos_release }}.tar repositories && cd ..
name: Tar git working copies
if: ${{ success() && env.mageos_release != '' && env.publish_tag == 'true' }}
- uses: actions/upload-artifact@v3
if: ${{ success() && env.mageos_release != '' && env.publish_tag == 'true' }}
with:
name: release-build-working-copies-${{ env.mageos_release }}
path: release-build-working-copies-${{ env.mageos_release }}.tar