-
Notifications
You must be signed in to change notification settings - Fork 51
133 lines (109 loc) · 3.49 KB
/
deploy-to-staging-site.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
name: "Deploy to staging site"
on:
pull_request:
branches:
- master
concurrency: ci-${{ github.event.number }}
env:
WEBAPP_NAME: antares-blog-staging
RESOURCE_GROUP: appserviceblogsite
SLOT_NAME: pr-${{ github.event.number }}
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v1
- name: Set up Ruby 3.0
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Install Ruby dependencies
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Build site
run: bundle exec jekyll build --future --baseurl=''
env:
JEKYLL_ENV: production
- name: zip up site
run: cd _site && zip -r ../blog.zip .
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: jekyll-app
path: blog.zip
set-up-test-env:
name: Create test env
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Run Azure Login with OIDC
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Azure CLI script
uses: azure/CLI@v2
with:
azcliversion: latest
inlineScript: |
az account show
- name: Create slot on staging site
run: |
az webapp deployment slot create \
--resource-group $RESOURCE_GROUP \
--name $WEBAPP_NAME \
--slot $SLOT_NAME
deploy-to-slot:
name: Deploy to test env
runs-on: ubuntu-latest
needs: [build, set-up-test-env]
environment:
name: "production"
url: "${{ steps.deploy-to-webapp.outputs.webapp-url }}"
permissions:
id-token: write
contents: read
pull-requests: write
steps:
- name: Run Azure Login with OIDC
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Azure CLI script
uses: azure/CLI@v2
with:
azcliversion: latest
inlineScript: |
az account show
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: jekyll-app
- name: Deploy to slot on staging site
uses: Azure/webapps-deploy@v3.0.0
with:
app-name: ${{ env.WEBAPP_NAME }}
slot-name: ${{ env.SLOT_NAME }}
package: blog.zip
- name: Comment on PR with the preview link
uses: mshick/add-pr-comment@v1
with:
message: |
## Preview link: https://antares-blog-staging-pr-${{ github.event.number }}.azurewebsites.net
- Your changes have been deployed to the preview site. The preview site will update as you add more commits to this branch.
- The preview site shows any future-dated articles. If you are publishing a future-dated article, it will not show on the production site until the file's specified date.
- The preview link is shareable, but will be deleted when this pull request is merged or closed.
> *This is an automated message.*
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'