-
Notifications
You must be signed in to change notification settings - Fork 3
52 lines (51 loc) · 2.19 KB
/
deploy.yml
File metadata and controls
52 lines (51 loc) · 2.19 KB
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
name: Deploy
on:
push:
tags:
- '**'
jobs:
deploy:
runs-on: ubuntu-latest
continue-on-error: false
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
- name: "Extract production files"
env:
DEPLOY_KEY: ${{ secrets.DEPLOYMENT_KEY }}
run: |
# Remove a possibly existing extraction folder
rm -rf extract
# Now that we are sure it's not there, create an empty extraction folder
mkdir extract
# Create an archive from the repository based on the given tag
# and extract that into the just created extraction folder.
git archive --prefix="./" --format=tar ${{ github.event.pull_request.head.sha || github.sha }} .| tar xv -C extract/
- name: "Cache calendar vendor dir"
uses: "actions/cache@v4"
with:
path: ${{ github.workspace }}/extract/vendor
key: "vendor-build-${{ hashFiles('*/composer.lock') }}"
- uses: "ramsey/composer-install@v3"
with:
dependency-versions: "locked"
working-directory: extract
composer-options: --no-dev --optimize-autoloader --classmap-authoritative
- name: "Archive build"
id: archive-build
run: |
buildfile="build-${{ github.event.pull_request.head.sha || github.sha }}.tar.gz"
tar --exclude-vcs -czf $buildfile -C extract/ .
- name: Configure SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
- name: "Deploy"
run: |
ssh-keyscan -t rsa ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
scp -r extract/* ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:/${{ secrets.REPO_PATH }}/${{ github.event.pull_request.head.sha || github.sha }}
ssh ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} "cd ${{ secrets.REPO_PATH }} && cp current/config/callingallpapers.ini ${{ github.event.pull_request.head.sha || github.sha }}/config/callingallpapers.ini && rm current && ln -sr ${{ github.event.pull_request.head.sha || github.sha }} current"