-
Notifications
You must be signed in to change notification settings - Fork 18
93 lines (79 loc) · 3 KB
/
gh-pages.yaml
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
on:
pull_request:
env:
FLUTTER_VERSION: 3.16.5
LIBOLM_VERSION: 3.2.16
name: Deploying on GitHub Pages
jobs:
deploy_preview:
name: Deploy preview versions on pull requests
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
permissions:
deployments: write
pull-requests: write
contents: write
environment:
name: PR-${{ github.event.pull_request.number }}
url: ${{ steps.configure.outputs.URL }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}"
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Setup Nix (to build libolm)
uses: cachix/install-nix-action@v26
- name: Build libolm
run: |
rm -rf assets/js
nix build -v "gitlab:matrix-org/olm/$LIBOLM_VERSION?host=gitlab.matrix.org#javascript" -o assets/js
sudo chmod 777 -R assets/js
cd assets/js/ && mv javascript package
- name: Build Web version
env:
FOLDER: ${{ github.event.pull_request.number }}
TWAKE_PREVIEW_CONFIG: ${{ secrets.TWAKE_PREVIEW_CONFIG }}
run: |
flutter config --enable-web
flutter clean
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build web --release --verbose --source-maps --base-href="/${GITHUB_REPOSITORY##*/}/$FOLDER/"
echo "$TWAKE_PREVIEW_CONFIG" | yq '.issue_id = strenv(FOLDER)' > ./build/web/config.json
- name: Configure environments
id: configure
env:
FOLDER: ${{ github.event.pull_request.number }}
run: |
echo "URL=https://$GITHUB_REPOSITORY_OWNER.github.io/${GITHUB_REPOSITORY##*/}/$FOLDER" >> $GITHUB_OUTPUT
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/web
keep_files: true
destination_dir: "${{ github.event.pull_request.number }}"
- name: Find deployment comment
uses: peter-evans/find-comment@v2
id: fc
with:
comment-author: "github-actions[bot]"
issue-number: ${{ github.event.pull_request.number }}
body-includes: "This PR has been deployed to"
- name: Create or update deployment comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
This PR has been deployed to ${{ steps.configure.outputs.URL }}
edit-mode: replace