14
14
env :
15
15
node-version : 13.10.1
16
16
dotnet : 3.1.100
17
- registry : docker.pkg.github.com
18
- repository : mystster/weatherdisp
17
+ registry : ghcr.io
19
18
image : weatherdisp
20
19
functionsApp : WeatherInfo
21
20
61
60
- name : ' Create Azure functions slot'
62
61
if : github.event.action == 'opened' || github.event.action == 'reopened'
63
62
run : |
64
- az functionapp deployment slot create --name ${{env.functionsApp}} --slot ${{needs.Prepare.outputs.SLOT_NAME}} --configuration-source stage --resource-group $RESOURCE_GROUP > /dev/null
65
- az functionapp config appsettings set --name ${{env.functionsApp}} --slot ${{needs.Prepare.outputs.SLOT_NAME}} --resource-group $RESOURCE_GROUP --settings "$(az functionapp config appsettings list --name ${{env.functionsApp}} --slot stage --resource-group $RESOURCE_GROUP | jq '[.[] | select(.name=="DARKSKY_API" or .name=="LAG" or .name=="LAT" or .name=="MAX_EXEC")]')" > /dev/null
63
+ az functionapp deployment slot create --name ${{env.functionsApp}} --slot ${{needs.Prepare.outputs.SLOT_NAME}} --configuration-source ${{env.functionsApp}} --resource-group $RESOURCE_GROUP > /dev/null
66
64
Build_frontend :
67
65
name : Build frontend using Vue.
68
66
runs-on : ubuntu-latest
@@ -126,6 +124,14 @@ jobs:
126
124
steps :
127
125
- name : Checkout
128
126
uses : actions/checkout@v2
127
+ - name : Set up Docker Buildx
128
+ uses : docker/setup-buildx-action@v1
129
+ - name : Login to GitHub Container Registry
130
+ uses : docker/login-action@v1
131
+ with :
132
+ registry : ${{ env.registry }}
133
+ username : ${{ github.repository_owner }}
134
+ password : ${{ secrets.CR_PAT }}
129
135
- name : Download frontend artifact
130
136
uses : actions/download-artifact@v2
131
137
with :
@@ -136,17 +142,33 @@ jobs:
136
142
with :
137
143
name : functions
138
144
path : images/artifacts
139
- - name : build image and push to github package registry
140
- uses : docker/build-push-action@v1
145
+ - name : Prepare
146
+ id : prep
147
+ run : |
148
+ VERSION=edge
149
+ if [[ $GITHUB_REF == refs/tags/* ]]; then
150
+ VERSION=${GITHUB_REF#refs/tags/}
151
+ elif [[ $GITHUB_REF == refs/heads/* ]]; then
152
+ VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
153
+ elif [[ $GITHUB_REF == refs/pull/* ]]; then
154
+ VERSION=pr-${{ github.event.number }}
155
+ fi
156
+ echo ::set-output name=version::${VERSION}
157
+ echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
158
+ - name : build image and push to GitHub Container Registry
159
+ uses : docker/build-push-action@v2
141
160
with :
142
- username : ${{ github.actor }}
143
- password : ${{ secrets.GITHUB_TOKEN }}
144
- repository : ${{ env.repository }}/${{ env.image }}
145
- registry : ${{ env.registry }}
146
- tags : latest, ${{needs.Prepare.outputs.BRANCH}}-latest, ${{needs.Prepare.outputs.TAG_NAME}}
147
- tag_with_ref : true
148
- add_git_labels : true
149
- path : images
161
+ push : true
162
+ context : images
163
+ tags : |
164
+ ${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:latest
165
+ ${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:${{ steps.prep.outputs.version }}
166
+ ${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:${{needs.Prepare.outputs.BRANCH}}-latest
167
+ ${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:${{needs.Prepare.outputs.TAG_NAME}}
168
+ labels : |
169
+ org.opencontainers.image.source=${{ github.event.repository.html_url }}
170
+ org.opencontainers.image.created=${{ steps.prep.outputs.created }}
171
+ org.opencontainers.image.revision=${{ github.sha }}
150
172
151
173
DeployPR :
152
174
name : Deploy functions container from PR
@@ -155,12 +177,12 @@ jobs:
155
177
steps :
156
178
- name : checkout
157
179
uses : actions/checkout@v2
158
- - name : Github package repositry login
180
+ - name : GitHub Container Registry login
159
181
uses : azure/docker-login@v1
160
182
with :
161
183
login-server : ${{ env.registry }}
162
- username : ${{ github.actor }}
163
- password : ${{ secrets.GITHUB_TOKEN }}
184
+ username : ${{ github.repository_owner }}
185
+ password : ${{ secrets.CR_PAT }}
164
186
- name : ' Login via Azure CLI'
165
187
uses : azure/login@v1
166
188
with :
@@ -170,7 +192,7 @@ jobs:
170
192
uses : Azure/functions-container-action@v1
171
193
with :
172
194
app-name : ${{ env.functionsApp }}
173
- image : ${{ env.registry }}/${{ env.repository }}/${{ env.image }}:${{needs.Prepare.outputs.TAG_NAME}}
195
+ image : ${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:${{needs.Prepare.outputs.TAG_NAME}}
174
196
slot-name : ${{needs.Prepare.outputs.SLOT_NAME}}
175
197
- name : ' comment access url'
176
198
uses : actions/github-script@v1
0 commit comments