generated from andskur/go-microservice-template
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (68 loc) · 2.01 KB
/
main.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
name: GitSec Backend CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2.5.1
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
go get -t -v ./...
- name: Run tests
run: |
make test
build:
name: Build and push Docker image
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.tag_version.outputs.new_tag }}
steps:
- uses: actions/checkout@v2
- name: Build
run: |
make build
- uses: docker/login-action@v1
name: Login to Docker Hub
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.0
with:
github_token: ${{ secrets.RELEASES_ACTION_GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
andskur/gitsec-backend:latest
andskur/gitsec-backend:${{ steps.tag_version.outputs.new_tag }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
token: ${{ secrets.RELEASES_ACTION_GITHUB_TOKEN }}
deploy:
needs: build
name: Deploy App on digital ocean
runs-on: ubuntu-latest
steps:
- name: DigitalOcean App Platform deployment
uses: digitalocean/app_action@main
with:
app_name: andskur-gitsec-backend
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}