-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (51 loc) · 1.75 KB
/
ci.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
name: CI
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build-n-deploy:
runs-on: ubuntu-latest
env:
GOOS: linux
GOARCH: amd64
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
cache: false
- name: Get Go cached paths
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
- name: Set up dependencies cache
uses: actions/cache@v3
with:
path: |
${{ env.cache }}
key: setup-go-deps-${{ runner.os }}-go-${{ hashFiles('go.sum go.mod') }}
- run: echo "$GOOS $GOARCH" > /tmp/env
- name: Set up intermediate built files cache
uses: actions/cache@v3
with:
path: |
${{ env.modcache }}
key: setup-go-build-${{ env.GOOS }}-${{ env.GOARCH }}-${{ runner.os }}-go-${{ hashFiles('**/*.go /tmp/env') }}
restore-keys: |
setup-go-build-${{ env.GOOS }}-${{ env.GOARCH }}
- name: Build Linux binary
run: go build
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/az-appservice .
- name: Login to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker push
run: docker push ${{ secrets.DOCKER_USERNAME }}/az-appservice
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: akv-demo-go
publish-profile: ${{ secrets.AZ_PROFILE }}