This repository has been archived by the owner on Aug 29, 2024. It is now read-only.
Merge pull request #164 from JenswBE/dependabot/go_modules/gorm.io/go… #420
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 and publish | |
on: | |
push: | |
branches: [main] | |
tags: | |
- "*" | |
pull_request: | |
env: | |
GO_VERSION: "1.22" # Also update Dockerfile when bumping | |
DOCKER_HUB_USER: jenswbebot | |
DOCKER_HUB_REPO: jenswbe/go-commerce | |
PLATFORMS: linux/amd64,linux/arm64 | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Derive docker_tag | |
id: vars | |
shell: python | |
run: | | |
import os | |
tag = os.environ['GITHUB_REF'].split('/').pop() | |
if tag == 'main': | |
tag = 'latest' | |
with open(os.environ['GITHUB_OUTPUT'], 'a') as output: | |
output.write(f"docker_tag={tag}{os.linesep}") | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
check-latest: true | |
go-version: ${{ env.GO_VERSION }} | |
- name: Pull common linter configs | |
run: wget -O .golangci.yml https://raw.githubusercontent.com/JenswBE/setup/main/programming_configs/golang/.golangci.yml | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
version: latest | |
args: >- | |
--timeout=5m | |
--disable errorlint,goerr113,nestif,noctx,wrapcheck | |
--exclude 'name will be used as .+ by other packages' | |
--exclude 'reassigning variable ErrorStackMarshaler in other package zerolog' | |
- name: Run unit tests | |
run: go test ./... | |
- name: Start E2E services | |
run: | | |
docker compose -f docker-compose.e2e.yml -f docker-compose.e2e.docker.yml up -d | |
sleep 10s | |
- name: Run E2E tests | |
working-directory: e2e | |
run: go test --tags e2e ./... | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
if: github.event_name == 'push' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKER_HUB_USER }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: ${{ env.PLATFORMS }} | |
push: ${{ github.event_name == 'push' }} | |
tags: ${{ env.DOCKER_HUB_REPO }}:${{ steps.vars.outputs.docker_tag }} | |
- name: Update repo description | |
if: github.event_name == 'push' | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ env.DOCKER_HUB_USER }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
repository: ${{ env.DOCKER_HUB_REPO }} |