mirror of
https://github.com/pushbits/server.git
synced 2025-04-29 10:16:50 +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
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
test_build_publish:
|
||||
name: Test, build, and publish
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Export GOBIN
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
|
||||
- name: Install dependencies
|
||||
run: make setup
|
||||
|
||||
- name: Run tests
|
||||
run: make test
|
||||
|
||||
- name: Build image
|
||||
run: make build_image
|
||||
- name: Login to Docker Hub
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Publish image
|
||||
run: make push_image
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- 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:
|
||||
go install github.com/fzipp/gocyclo/cmd/gocyclo@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:
|
||||
server:
|
||||
image: eikendev/pushbits:latest
|
||||
image: ghcr.io/pushbits/server:latest
|
||||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
|
|
Loading…
Add table
Reference in a new issue