-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (96 loc) · 4.5 KB
/
Copy pathdeploy_github_pages.yml
File metadata and controls
104 lines (96 loc) · 4.5 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
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
name: Deploy to GitHub Pages
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
remote_file_url:
description: 'Remote file URL'
required: false
remote_file_type:
description: 'Remote file type'
required: false
default: ''
type: choice
options:
- ''
- 7z
- tar
remote_file_password:
description: 'Remote file password'
required: false
permissions:
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Download and extract remote file
env:
DEFAULT_REMOTE_FILE_URL: ${{ secrets.REMOTE_FILE_URL }}
DEFAULT_REMOTE_FILE_TYPE: ${{ secrets.REMOTE_FILE_TYPE }}
DEFAULT_REMOTE_FILE_PASSWORD: ${{ secrets.REMOTE_FILE_PASSWORD }}
INPUTS_REMOTE_FILE_URL: ${{ github.event.inputs.remote_file_url }}
INPUTS_REMOTE_FILE_TYPE: ${{ github.event.inputs.remote_file_type }}
INPUTS_REMOTE_FILE_PASSWORD: ${{ github.event.inputs.remote_file_password }}
shell: bash
run: |
if [ -n "${INPUTS_REMOTE_FILE_URL:+x}" ]; then
REMOTE_FILE_URL="${INPUTS_REMOTE_FILE_URL}";
elif [ -n "${DEFAULT_REMOTE_FILE_URL:+x}" ]; then
REMOTE_FILE_URL="${DEFAULT_REMOTE_FILE_URL}";
else
echo 'Error: REMOTE_FILE_URL not specified';
exit 1;
fi
if [ -n "${INPUTS_REMOTE_FILE_TYPE:+x}" ]; then
REMOTE_FILE_TYPE="${INPUTS_REMOTE_FILE_TYPE}";
elif [ -n "${DEFAULT_REMOTE_FILE_TYPE:+x}" ]; then
REMOTE_FILE_TYPE="${DEFAULT_REMOTE_FILE_TYPE}";
else
echo 'Error: REMOTE_FILE_TYPE not specified';
exit 1;
fi
if [ -n "${INPUTS_REMOTE_FILE_PASSWORD:+x}" ]; then
export REMOTE_FILE_PASSWORD="${INPUTS_REMOTE_FILE_PASSWORD}";
elif [ -n "${DEFAULT_REMOTE_FILE_PASSWORD:+x}" ]; then
export REMOTE_FILE_PASSWORD="${DEFAULT_REMOTE_FILE_PASSWORD}";
else
echo 'REMOTE_FILE_PASSWORD not specified';
fi
if [ "${REMOTE_FILE_TYPE:?invalid}" = 'tar' ]; then
if [ -n "${REMOTE_FILE_PASSWORD:+x}" ]; then
echo 'Download --> decrypt --> extract as tar';
curl -fsSL "${REMOTE_FILE_URL:?invalid}" | openssl enc -d -aes-256-cbc -pbkdf2 -pass env:REMOTE_FILE_PASSWORD -in - -out - | tar -xzvf -;
else
echo 'Download --> extract as tar';
curl -fsSL "${REMOTE_FILE_URL:?invalid}" | tar -xzvf -;
fi
elif [ "${REMOTE_FILE_TYPE:?invalid}" = '7z' ]; then
if [ -n "${REMOTE_FILE_PASSWORD:+x}" ]; then
echo 'Download --> decrypt & extract as 7z';
rm -f /tmp/www.7z && curl -fsSL -o /tmp/www.7z "${REMOTE_FILE_URL:?invalid}" && 7z x "-p${REMOTE_FILE_PASSWORD:?invalid}" /tmp/www.7z;
rm -f /tmp/www.7z;
else
echo 'Download --> extract as 7z';
rm -f /tmp/www.7z && curl -fsSL -o /tmp/www.7z "${REMOTE_FILE_URL:?invalid}" && 7z x /tmp/www.7z;
rm -f /tmp/www.7z;
fi
else
echo "Error: unsupported file type: ${REMOTE_FILE_TYPE:?invalid}";
exit 1;
fi
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4