forked from jamespfennell/transiter
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (97 loc) · 3.91 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Build
on: [push, pull_request]
jobs:
build-and-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.18.0'
- name: Set the version
run: |
BASE_VERSION=$(cat internal/version/BASE_VERSION)
VERSION=${BASE_VERSION}-alpha+build${{ github.run_number }}
# If this is a push to mainline, give it the beta release
if [ "${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}" = "true" ]
then
VERSION=${BASE_VERSION}-beta.${{ github.run_number }}
fi
# If this is a release, give it the full version.
# A release is defined as a tag push where the tag is `v<base version>`.
if [ "${{ github.ref }}" = "refs/tags/v${BASE_VERSION}" ]
then
VERSION=${BASE_VERSION}
fi
echo "Setting version to ${VERSION}"
echo "TRANSITER_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Go build
run: go build .
- name: Launch Postgres
run: docker run -d --env POSTGRES_USER=transiter --env POSTGRES_PASSWORD=transiter --env POSTGRES_DB=transiter -p 5432:5432 postgres:12
- name: Go test
run: go test ./...
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build the Docker image
uses: docker/build-push-action@v4
with:
tags: |
jamespfennell/transiter:latest
build-args: |
"TRANSITER_VERSION=${{ env.TRANSITER_VERSION }}"
outputs: type=docker
context: .
- name: End-to-end tests (setup)
run: docker-compose -f tests/endtoend/compose.yml up --build --detach sourceserver transiter db
- name: End-to-end tests (run)
run: docker-compose -f tests/endtoend/compose.yml up --build --exit-code-from testrunner testrunner
- name: Linter
run: go install honnef.co/go/tools/cmd/[email protected] && staticcheck ./...
- name: Login to DockerHub
uses: docker/login-action@v2
# Only push to Docker Hub if this workflow is a push to mainline
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
with:
username: jamespfennell
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v4
# Only push to Docker Hub if this workflow is a push to mainline
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
with:
build-args: |
"TRANSITER_VERSION=${{ env.TRANSITER_VERSION }}"
jamespfennell/transiter:latest
tags: |
jamespfennell/transiter:${{ env.TRANSITER_VERSION }}
context: .
push: true
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build the Docker image
uses: docker/build-push-action@v4
with:
file: docs/Dockerfile
tags: jamespfennell/transiter-docs:latest
outputs: type=docker
context: .
- name: Login to DockerHub
uses: docker/login-action@v2
# Only push to Docker Hub if this workflow is a push to mainline
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
with:
username: jamespfennell
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v4
# Only push to Docker Hub if this workflow is a push to mainline
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
with:
tags: jamespfennell/transiter-docs:latest
file: docs/Dockerfile
context: .