-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (73 loc) · 2.89 KB
/
publish.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
on:
push:
branches: [main]
jobs:
publish:
name: Publish to Cloudflare Pages
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: dorny/paths-filter@v3
id: files_changed
with:
list-files: "shell"
filters: |
deps:
- "package-lock.json"
lib:
- "packages/common/**/*"
sites:
- "sites/**/*"
# - if: steps.files_changed.outputs.src == 'true'
# run: ...
- name: Build Matrix
id: sites_matrix
run: |
if [${{steps.files_changed.outputs.deps == "true"}}] || [${{steps.files_changed.outputs.lib == "true"}}]
then
# core changes - deploy all sites
echo SITES=$()
# all_sites=($(find ./sites -maxdepth 1 -mindepth 1 -type d ! -name ./sites -exec basename {} \;))
# echo SITES="${all_sites[@]}"
echo SITES=($(find ./sites -maxdepth 1 -mindepth 1 -type d ! -name ./sites -exec basename {} \;)) >> $GITHUB_OUTPUT;
elif [${{steps.files_changed.outputs.sites == "true"}}]
then
site_paths=(${{steps.files_changed.outputs.sites_files}})
sites=()
for i in "${site_paths[@]}";
do
sites_directory="${i#*sites/}"
sites_directory="${sites_directory%%/*}"
sites+=("$sites_directory")
done
unique_sites=($(echo "${sites[@]}" | tr ' ' '\n' | sort -u))
echo SITES="${unique_sites[@]}" >> $GITHUB_OUTPUT;
else
echo SITES=() >> $GITHUB_OUTPUT;
fi
- name: List Changed Files
run: |
echo "Changed lib files: ${{ steps.files_changed.outputs.lib_files }}"
echo "Changed sites files: ${{ steps.files_changed.outputs.sites_files }}"
echo "Sites Matrix: ${{ toJson(steps.sites_matrix.outputs.SITES) }}"
# Run a build step here if your project requires
# - name: Publish to Cloudflare Pages
# uses: cloudflare/pages-action@v1
# with:
# apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
# accountId: YOUR_ACCOUNT_ID
# projectName: YOUR_PROJECT_NAME
# directory: YOUR_BUILD_OUTPUT_DIRECTORY
# # Optional: Enable this if you want to have GitHub Deployments triggered
# gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# # Optional: Switch what branch you are publishing to.
# # By default this will be the branch which triggered this workflow
# branch: main
# # Optional: Change the working directory
# workingDirectory: my-site
# # Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta`
# wranglerVersion: "3"