-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (53 loc) · 1.54 KB
/
build.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
name: Build and Deploy
on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
- name: Restore
run: dotnet restore src/Giraffe.Website/Giraffe.Website.fsproj
- name: Build
run: dotnet build --configuration Release --no-restore src/Giraffe.Website/Giraffe.Website.fsproj
deploy:
needs: build
if: github.event_name == 'release'
runs-on: ubuntu-latest
env:
PROJECT: giraffefsharp
IMAGE: giraffe-website
steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v2
# Build the Docker image
- name: Build Docker image
run: |
PATTERN="refs/tags/v"
SUB=""
TAG="${GITHUB_REF/$PATTERN/$SUB}"
docker build --build-arg version=$TAG -t "$PROJECT"/"$IMAGE":"$TAG" -f src/Giraffe.Website/Dockerfile .
# Auth with Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
# Push the Docker image to Docker Hub
- name: Publish Docker image
run: |
PATTERN="refs/tags/v"
SUB=""
TAG="${GITHUB_REF/$PATTERN/$SUB}"
docker push $PROJECT/$IMAGE:$TAG