2021-03-04 00:21:05 +00:00
|
|
|
name: main
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2023-09-15 22:14:18 +00:00
|
|
|
- 'main'
|
|
|
|
- 'v\d+.\d+.\d+'
|
2021-03-04 00:21:05 +00:00
|
|
|
pull_request:
|
2023-09-15 22:14:18 +00:00
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
- 'v\d+.\d+.\d+'
|
2021-03-04 00:21:05 +00:00
|
|
|
jobs:
|
2023-09-15 22:14:18 +00:00
|
|
|
test:
|
2021-12-20 21:00:31 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-15 22:14:18 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-go@v4
|
2021-03-04 00:21:05 +00:00
|
|
|
with:
|
2023-09-15 22:14:18 +00:00
|
|
|
go-version: 1.21.1
|
|
|
|
- run: cd backend && go test -race -v ./...
|
2021-12-20 21:00:31 +00:00
|
|
|
lint:
|
2021-03-04 00:21:05 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-15 22:14:18 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-go@v4
|
2021-03-04 00:21:05 +00:00
|
|
|
with:
|
2023-09-15 22:14:18 +00:00
|
|
|
go-version: 1.21.1
|
|
|
|
- run: cd backend && go fmt ./...
|
|
|
|
push_to_registry:
|
2021-03-04 00:21:05 +00:00
|
|
|
needs: [lint, test]
|
2023-09-15 22:14:18 +00:00
|
|
|
name: Push Docker image to Docker Hub
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: contains(github.ref, 'main') || startsWith(github.ref,'v0.')
|
2021-03-04 00:21:05 +00:00
|
|
|
steps:
|
2023-09-15 22:14:18 +00:00
|
|
|
- name: Check out the repo
|
|
|
|
uses: actions/checkout@v4
|
2021-03-04 00:21:05 +00:00
|
|
|
- name: Set up QEMU
|
2023-09-15 22:14:18 +00:00
|
|
|
uses: docker/setup-qemu-action@v3
|
2021-03-04 00:21:05 +00:00
|
|
|
- name: Set up Docker Buildx
|
2023-09-15 22:14:18 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
|
|
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
2021-03-04 00:21:05 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2023-09-15 22:14:18 +00:00
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
|
|
|
with:
|
|
|
|
images: gtstef/filebrowser
|
|
|
|
- name: Build and push
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
|
|
file: ./Dockerfile
|
|
|
|
push: true
|
|
|
|
tags: ${{ contains(github.ref, 'main') && 'latest' || steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|