Fix url scheme #103
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: . |