This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (64 loc) · 1.78 KB
/
dockerpush.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Docker
on:
push:
branches:
- main
tags:
- v*
pull_request:
env:
IMAGE_NAME: tweety
jobs:
build_test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
dotnet-quality: "preview"
- name: Restore Dependencies
run: dotnet restore
- name: Build All
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-restore --no-build --configuration Release
docker_test:
runs-on: ubuntu-22.04
needs: build_test
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Build Image
run: docker build . -t $IMAGE_NAME
build_push_image:
runs-on: ubuntu-22.04
if: github.event_name == 'push'
needs: build_test
steps:
- uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
berviantoleo/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}