-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (89 loc) · 3.31 KB
/
prepare-static-app.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
name: Prepare Static App
on:
push:
branches: [ main ]
paths: workables/**
schedule:
- cron: '0 3 * * *' # run at 03 AM UTC
workflow_dispatch:
jobs:
build-static-app:
runs-on: ubuntu-latest
steps:
- name: checkout-code
uses: actions/[email protected]
- name: setup-dotnet
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
- name: build-builder
run: dotnet build ./_src/Blog.Builder.sln --configuration Release
- name: publish-builder
run: dotnet publish ./_src/Blog.Builder.sln --configuration Release --output tmp
- name: build-output
run: |
cd tmp
dotnet Blog.Builder.dll --workables ../workables --output ../_output
- name: push-output
id: push_output
run: |
cd _output
branchbasename=build-$(date +"%Y.%m.%d-%H.%M.%S")-${{ github.run_number }}
branchname=feature/${branchbasename}
git config user.name blogbot
git config user.email [email protected]
git pull
git branch ${branchname}
git push --set-upstream origin ${branchname}
git checkout ${branchname}
git add .
git commit --allow-empty -m "Automated static files build"
git push
echo "::set-output name=branchname::${branchname}"
- name: pull-request
uses: actions/github-script@v6
with:
script: |
title = '[User Added Content] User ${{ github.actor }} has added new content that is ready to be published.'
if( '${{ github.event_name }}' == 'schedule' ) {
title = '[Nightly Build] Automated publishment triggered by a schedule.'
}
if( '${{ github.event_name }}' == 'workflow_dispatch' ) {
title = '[Manual Trigger] User ${{ github.actor }} triggered this workflow.'
}
const { repo, owner } = context.repo;
const pr = await github.rest.pulls.create({
title: title,
owner,
repo,
head: '${{ steps.push_output.outputs.branchname }}',
base: 'main',
body: [
'This PR is auto-generated by',
'[actions/github-script](https://github.com/actions/github-script).'
].join('\n')
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: pr.data.number,
labels: ['${{ github.event_name }}', 'automated-pr']
});
if( '${{ github.event_name }}' == 'schedule' ) {
github.rest.pulls.merge({
owner,
repo,
pull_number: pr.data.number,
});
}
# When you use the repository's GITHUB_TOKEN to perform tasks,
# events triggered by the GITHUB_TOKEN will not create a new workflow run.
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
- name: deploy
uses: Azure/static-web-apps-deploy@v1
if: ${{ github.event_name }} == 'schedule'
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_DEPLOYMENT_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/_output"