-
Notifications
You must be signed in to change notification settings - Fork 13
92 lines (73 loc) · 2.54 KB
/
deploy-pull-request.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
name: Deploy PR to staging env
on:
pull_request:
branches:
- main
concurrency: ci-${{ github.event.number }}
env:
WEBAPP_NAME: replace-with-your-webapp-name
RESOURCE_GROUP: replace-with-your-rg-name
SLOT_NAME: pr-${{ github.event.number }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v1
- name: Set up Java 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: microsoft
- name: Build app
run: mvn clean package
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: java-app
path: '${{ github.workspace }}/target/*.war'
set-up-test-env:
name: Create test env
runs-on: ubuntu-latest
steps:
- name: Log into Azure CLI with service principal
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create slot on staging site
run: az webapp deployment slot create --resource-group $RESOURCE_GROUP --name $WEBAPP_NAME --slot $SLOT_NAME
deploy:
name: Deploy to test env
runs-on: ubuntu-latest
needs: [build, set-up-test-env]
environment:
name: "PR #${{ github.event.number }}"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
pull-requests: write
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: java-app
- name: Log into Azure CLI with service principal
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to slot on staging site
uses: azure/webapps-deploy@v1
id: deploy-to-webapp
with:
app-name: ${{ env.WEBAPP_NAME }}
slot-name: ${{ env.SLOT_NAME }}
package: '*.war'
- name: Comment on PR with the preview link
uses: mshick/add-pr-comment@v1
with:
message: |
## Preview link: https://${{ env.WEBAPP_NAME }}-${{env.SLOT_NAME }}.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 link is shareable, but will be deleted when the pull request is merged or closed.
> *This is an automated message.*
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'