-
Notifications
You must be signed in to change notification settings - Fork 4
89 lines (84 loc) · 3.07 KB
/
preview.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
name: Preview Deployment
on:
pull_request:
workflow_dispatch:
# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
id-token: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
environment: netcup-bitbetter
env:
ASTRO_CONFIG: ${{ secrets.ASTRO_CONFIG }}
PUBLIC_MAPBOX_TOKEN: ${{ secrets.PUBLIC_MAPBOX_TOKEN }}
AIRTABLE_TOKEN: ${{ secrets.AIRTABLE_TOKEN }}
INTERVENTIONS_AIRTABLE_BASE_ID: ${{ secrets.INTERVENTIONS_AIRTABLE_BASE_ID }}
NEWS_AIRTABLE_BASE_ID: ${{ secrets.NEWS_AIRTABLE_BASE_ID }}
steps:
- name: Set env to use shell substitution logic
run: echo "ASTRO_BASE_PATH=${GITHUB_HEAD_REF//\//-}" >> $GITHUB_ENV
- name: Checkout repository using git
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 22
- name: Replace config file with Prod version
run: echo "$ASTRO_CONFIG" > astro.config.mjs
- run: cat astro.config.mjs
- name: Install Node dependencies
run: npm ci
- name: Build site
run: npm run build
- name: Move images Interventions
run: mv public/images/interventions/dynamic/* dist/images/interventions/dynamic/
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: deployment
retention-days: 5
path: ./dist
deploy:
needs: build
environment: netcup-bitbetter
runs-on: ubuntu-latest
env:
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_PATH: ${{ secrets.SFTP_PATH }}
SFTP_USER: ${{ secrets.SFTP_USER }}
SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }}
steps:
# - name: Set env to use shell substitution logic
# run: echo "ASTRO_BASE_PATH=${GITHUB_HEAD_REF//\//-}" >> $GITHUB_ENV
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: deployment
path: dist
- name: Install LFTP
run: sudo apt-get install -y lftp
- name: Add SSH Known Hosts
run: |
mkdir -p ~/.ssh/
echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- name: List dir
run: |
pwd
ls -la
- name: Deploy via LFTP to SFTP target
run: lftp -e "set ftp:list-options -a; set net:timeout 5; set net:max-retries 3; set net:reconnect-interval-base 5; open sftp://$SFTP_HOST; user $SFTP_USER $SFTP_PASSWORD; mirror --reverse --only-newer --ignore-time --verbose --delete ./dist ./$SFTP_PATH/${GITHUB_HEAD_REF//\//-} --exclude pdfjs/ ; bye"
- name: Comment on PR
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ Successfully deployed to: https://${GITHUB_HEAD_REF}.dev.tolocar.org/'
})