forked from skohub-io/skohub-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (113 loc) · 4.02 KB
/
main.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
124
125
126
127
128
129
130
131
132
133
134
name: Build /public and deploy to gh-pages with docker container
on:
push:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Test scenario tags'
jobs:
all-ttl-files:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.file-list }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Find TTL files
id: find-ttl
run: |
ttl_files=$(find . -name '*.ttl' -printf '"%p",' | sed 's/,$//')
echo "ttl_files=$ttl_files"
echo "ttl_files=$ttl_files" >> "$GITHUB_ENV"
- name: Set matrix for TTL files
id: set-matrix
run: echo "file-list=[${ttl_files}]" >> $GITHUB_OUTPUT
- name: List all changed files
run: echo "${ttl_files}"
changedfiles:
runs-on: ubuntu-latest
outputs:
ttl: ${{ steps.set-ttl-matrix.outputs.ttl }}
yml: ${{ steps.set-yml-matrix.outputs.yml }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Get changed ttl-files
id: changed-ttl-files
uses: tj-actions/changed-files@v42
with:
files: |
**/*.ttl
json: true
- name: Get changed yml-files
id: changed-yml-files
uses: tj-actions/changed-files@v42
with:
files: |
**/*.yml
**/*.yaml
json: true
- name: Set turtle file matrix
id: set-ttl-matrix
run: echo "ttl=${{ steps.changed-ttl-files.outputs.all_changed_files }}" >> $GITHUB_OUTPUT
- name: Set yml file matrix
id: set-yml-matrix
run: echo "yml=${{ steps.changed-yml-files.outputs.all_changed_files }}" >> $GITHUB_OUTPUT
prepare-matrix:
runs-on: ubuntu-latest
needs: [changedfiles, all-ttl-files]
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Determine matrix
id: set-matrix
run: |
changed_files_ttl=${{ toJSON(needs.changedfiles.outputs.ttl) }}
changed_files_yml=${{ toJSON(needs.changedfiles.outputs.yml) }}
if [ $(echo "$changed_files_ttl" | jq length) -gt 0 ]; then
echo "matrix=${{ toJSON(needs.changedfiles.outputs.ttl) }}" >> $GITHUB_OUTPUT
elif [ $(echo "$changed_files_yml" | jq length) -gt 0 ]; then
echo "matrix=${{ toJSON(needs.all-ttl-files.outputs.matrix) }}" >> $GITHUB_OUTPUT
else
echo "matrix=[]" >> $GITHUB_OUTPUT
fi
build:
runs-on: ubuntu-latest
needs: [prepare-matrix]
if: ${{ needs.prepare-matrix.outputs.matrix != '[]'}}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
with:
persist-credentials: false
- name: remove public and data-dir if already exists
run: rm -rf public data
- run: mkdir public
- run: chmod -R 777 public # user in container is node which won't have write access to public
- run: mkdir data
- run: chmod -R 777 data # user in container is node which won't have write access to public
- run: git clone https://github.com/$GITHUB_REPOSITORY.git data/
- name: make .env file
run: |
input=$GITHUB_REPOSITORY
repo=${input#*/}
echo "BASEURL=/$repo" > .env
- name: build public dir with docker image
run: >
docker run
-v $(pwd)/public:/app/public
-v $(pwd)/data:/app/data
-v $(pwd)/.env:/app/.env
-v $(pwd)/config.yaml:/app/config.yaml
-e GATSBY_RESPOSITORY_URL=https://github.com/$GITHUB_REPOSITORY
skohub/skohub-vocabs-docker:latest
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public