-
Notifications
You must be signed in to change notification settings - Fork 8
103 lines (91 loc) · 3.06 KB
/
stage.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
name: Stage the app
on:
pull_request:
types: [labeled]
env:
DOCKER_IMAGE_NAME: deployment-nodeapp-azure
IMAGE_REGISTRY_URL: docker.pkg.github.com
#################################################
### USER PROVIDED VALUES ARE REQUIRED BELOW ###
#################################################
#################################################
### REPLACE USERNAME WITH GH USERNAME ###
AZURE_WEBAPP_NAME: irvv17-deployment-nodeapp-azure
#################################################
jobs:
build:
if: contains(github.event.pull_request.labels.*.name, 'stage')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: npm install and build webpack
run: |
npm install
npm run build --if-present
- name: Creating artifact directories
run: |
mkdir buildartifacts
# Archive build artifact
- name: Archive Application
uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./buildartifacts/application.zip ./
# Uploading application to build artifact
- name: Upload Application to Build Artifact
continue-on-error: false
uses: actions/upload-artifact@v2
with:
name: buildartifacts
path: buildartifacts
Build-Docker-Image:
runs-on: ubuntu-latest
needs: build
name: Build image and store in GitHub Packages
steps:
# Downloading build artifact
- name: Download a Build Artifact
uses: actions/download-artifact@v2
continue-on-error: false
with:
name: buildartifacts
path: buildartifacts
# Uzipping build artifacts
- name: unzipping build artifact
uses: montudor/action-zip@v0.1.0
with:
args: unzip -qq ./buildartifacts/application.zip -d .
- name: create image and store in Packages
uses: mattdavis0351/actions/docker-gpr@1.3.0
with:
repo-token: ${{secrets.GITHUB_TOKEN}}
image-name: ${{env.DOCKER_IMAGE_NAME}}
tag: latest
- name: delete-package-versions
uses: actions/delete-package-versions@v1
with:
package-name: ${{env.DOCKER_IMAGE_NAME}}
num-old-versions-to-delete: 1
Deploy-to-Azure:
runs-on: ubuntu-latest
needs: Build-Docker-Image
name: Deploy app container to Azure
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
- name: "Login via Azure CLI"
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: azure/docker-login@v1
with:
login-server: ${{env.IMAGE_REGISTRY_URL}}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy web app container
uses: azure/webapps-deploy@v2
with:
app-name: ${{env.AZURE_WEBAPP_NAME}}
images: ${{env.IMAGE_REGISTRY_URL}}/${{ github.repository }}/${{env.DOCKER_IMAGE_NAME}}:${{ github.sha }}
- name: Azure logout
run: |
az logout