ci: migrate to github actions
parent
35a4379b67
commit
47578e02e3
|
@ -1,70 +0,0 @@
|
|||
version: 2.1
|
||||
references:
|
||||
base_container: &base_container
|
||||
docker:
|
||||
- image: filebrowser/builder:v1.1.0
|
||||
jobs:
|
||||
lint:
|
||||
<<: *base_container
|
||||
steps:
|
||||
- checkout
|
||||
- run: make lint
|
||||
test:
|
||||
<<: *base_container
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Test"
|
||||
command: make test
|
||||
build:
|
||||
<<: *base_container
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Build"
|
||||
command: make build
|
||||
- run:
|
||||
name: "Cleanup"
|
||||
command: |
|
||||
rm -rf frontend/node_modules
|
||||
rm -rf bin/
|
||||
- persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- '*'
|
||||
release:
|
||||
<<: *base_container
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: '~/project'
|
||||
- setup_remote_docker
|
||||
- run: echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
|
||||
- run: curl -sL https://git.io/goreleaser | bash
|
||||
- run: docker logout
|
||||
workflows:
|
||||
version: 2
|
||||
build-workflow:
|
||||
jobs:
|
||||
- lint:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
- test:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
- build:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
- release:
|
||||
context: deploy
|
||||
requires:
|
||||
- build
|
||||
- test
|
||||
- lint
|
||||
filters:
|
||||
tags:
|
||||
only: /^v.*/
|
||||
branches:
|
||||
ignore: /.*/
|
|
@ -0,0 +1,5 @@
|
|||
# These owners will be the default owners for everything in the repo.
|
||||
# Unless a later match takes precedence, @o1egl will be requested for
|
||||
# review when someone opens a pull request.
|
||||
|
||||
* @o1egl
|
|
@ -0,0 +1,66 @@
|
|||
name: main
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
- run: npm i -g commitlint
|
||||
- run: make lint
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
- run: make test
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint, test]
|
||||
if: startsWith(github.event.ref, 'refs/tags/v')
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Build fronetend
|
||||
run: make build-frontend
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
|
@ -5,7 +5,7 @@ env:
|
|||
|
||||
before:
|
||||
hooks:
|
||||
- go mod download
|
||||
- make bundle-frontend
|
||||
|
||||
build:
|
||||
env:
|
||||
|
|
27
Dockerfile
27
Dockerfile
|
@ -7,31 +7,4 @@ EXPOSE 80
|
|||
|
||||
COPY filebrowser /filebrowser
|
||||
|
||||
# Create appuser.
|
||||
ENV USER=root
|
||||
ENV GROUP=root
|
||||
ENV UID=0
|
||||
ENV GID=0
|
||||
ENV UMASK=022
|
||||
|
||||
RUN if [ "$GID" -ne 0 ]; then \
|
||||
addgroup \
|
||||
-g "${GID}" \
|
||||
"${GROUP}" ; \
|
||||
fi;
|
||||
|
||||
RUN adduser \
|
||||
-g "" \
|
||||
-D \
|
||||
-G "${GROUP}" \
|
||||
-H \
|
||||
-h "/nonexistent" \
|
||||
-s "/sbin/nologin" \
|
||||
-u "${UID}" \
|
||||
"${USER}"
|
||||
|
||||
USER ${USER}:${GROUP}
|
||||
|
||||
RUN umask ${UMASK}
|
||||
|
||||
ENTRYPOINT [ "/filebrowser" ]
|
6
Makefile
6
Makefile
|
@ -51,10 +51,12 @@ build-frontend: | ; $(info $(M) building frontend…)
|
|||
|
||||
## build-backend: Build backend
|
||||
.PHONY: build-backend
|
||||
build-backend: | $(RICE) ; $(info $(M) building backend…)
|
||||
$Q cd ./http && rm -rf rice-box.go && $(RICE) embed-go
|
||||
build-backend: bundle-frontend | ; $(info $(M) building backend…)
|
||||
$Q $(GO) build -ldflags '$(LDFLAGS)' -o filebrowser
|
||||
|
||||
bundle-frontend: | $(RICE) ; $(info $(M) building backend…)
|
||||
$Q cd ./http && rm -rf rice-box.go && $(RICE) embed-go
|
||||
|
||||
## test: Run all tests
|
||||
.PHONY: test
|
||||
test: | test-frontend test-backend ; $(info $(M) running tests…)
|
||||
|
|
Loading…
Reference in New Issue