mirror of
https://github.com/pushbits/server.git
synced 2025-05-01 19:26:41 +02:00
Publish image to GitHub's registry
This commit is contained in:
parent
90e98acba5
commit
2bd5e2a3c8
3 changed files with 35 additions and 14 deletions
39
.github/workflows/publish.yml
vendored
39
.github/workflows/publish.yml
vendored
|
@ -1,29 +1,58 @@
|
||||||
name: Publish
|
name: Publish
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test_build_publish:
|
test_build_publish:
|
||||||
name: Test, build, and publish
|
name: Test, build, and publish
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Export GOBIN
|
- name: Export GOBIN
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.16
|
go-version: 1.16
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: make setup
|
run: make setup
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: make test
|
run: make test
|
||||||
|
|
||||||
- name: Build image
|
- name: Build image
|
||||||
run: make build_image
|
run: make build_image
|
||||||
- name: Login to Docker Hub
|
|
||||||
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
registry: ${{ env.REGISTRY }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
username: ${{ github.actor }}
|
||||||
- name: Publish image
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: make push_image
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v3
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
8
Makefile
8
Makefile
|
@ -20,11 +20,3 @@ test:
|
||||||
setup:
|
setup:
|
||||||
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
|
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
|
||||||
go install honnef.co/go/tools/cmd/staticcheck@latest
|
go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||||
|
|
||||||
.PHONY: build_image
|
|
||||||
build_image:
|
|
||||||
docker build -t ${IMAGE}:latest .
|
|
||||||
|
|
||||||
.PHONY: push_image
|
|
||||||
push_image:
|
|
||||||
docker push ${IMAGE}:latest
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ version: '2'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
server:
|
server:
|
||||||
image: eikendev/pushbits:latest
|
image: ghcr.io/pushbits/server:latest
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Add table
Reference in a new issue