Change Github workflow to deploy docker image

This commit is contained in:
Paul-Christian Volkmer 2023-09-02 14:03:39 +02:00
parent 3936666ecc
commit 925f4c3f5a
3 changed files with 38 additions and 17 deletions

34
.github/workflows/go-deploy.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Deploy
on:
push:
branches: [ "master", "main" ]
pull_request:
branches: [ "master", "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.20'
- run: go test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Execute image build and push
run: |
docker build -t ghcr.io/pcvolkmer/idicon .
docker push ghcr.io/pcvolkmer/idicon

View File

@ -1,17 +0,0 @@
name: Go test
on:
push:
branches: [ "master", "main" ]
pull_request:
branches: [ "master", "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.20'
- run: go test

View File

@ -21,6 +21,10 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app -ldflags '-w -s'
FROM scratch
LABEL org.opencontainers.image.source = "https://github.com/pcvolkmer/idicon"
LABEL org.opencontainers.image.licenses = "MIT"
LABEL org.opencontainers.image.description = "Simple identicon service"
COPY --from=build-env /etc/passwd /etc/passwd
COPY --from=build-env /etc/group /etc/group
COPY --from=build-env /tmp/build/app /idicon