|
1 | | -name: Docker Image CI |
| 1 | +name: Build & Publish Container |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [ "master" ] |
6 | | - #pull_request: |
7 | | - # branches: [ "master" ] |
| 5 | + branches: [ master ] |
8 | 6 |
|
9 | 7 | jobs: |
10 | | - |
11 | | - build: |
12 | | - |
| 8 | + publish: |
13 | 9 | runs-on: ubuntu-latest |
14 | 10 |
|
15 | 11 | steps: |
16 | | - |
17 | | - - uses: actions/checkout@v3 |
18 | | - |
19 | | - - name: Move Dockerfile to solution directory |
20 | | - run: mv ./src/BF2WebAdmin.Server/Dockerfile . |
21 | | - |
22 | | - #- name: Build the Docker image |
23 | | - # run: docker build . --file Dockerfile --tag bf2-webadmin:$(date +%s) |
| 12 | + - name: Checkout |
| 13 | + uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Install .NET 9 |
| 16 | + uses: actions/setup-dotnet@v3 |
| 17 | + with: |
| 18 | + dotnet-version: '9.0.x' |
24 | 19 |
|
25 | | - - name: Log in to Docker Hub |
26 | | - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 |
27 | | - with: |
28 | | - username: ${{ secrets.DOCKER_USERNAME }} |
29 | | - password: ${{ secrets.DOCKER_PASSWORD }} |
| 20 | + - name: Run tests |
| 21 | + run: dotnet test |
30 | 22 |
|
31 | | - - name: Extract metadata (tags, labels) for Docker |
32 | | - id: meta |
33 | | - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 |
34 | | - with: |
35 | | - images: nihlen/bf2-webadmin |
36 | | - tags: | |
37 | | - type=sha |
38 | | - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} |
39 | | - |
40 | | - - name: Build and push Docker image |
41 | | - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc |
42 | | - with: |
43 | | - context: . |
44 | | - push: true |
45 | | - tags: ${{ steps.meta.outputs.tags }} |
46 | | - labels: ${{ steps.meta.outputs.labels }} |
| 23 | + - name: Build & push container to Docker Hub |
| 24 | + env: |
| 25 | + # set these in your repo secrets |
| 26 | + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} |
| 27 | + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} |
| 28 | + run: | |
| 29 | + dotnet publish -c Release \ |
| 30 | + -p:ContainerRegistry=docker.io \ |
| 31 | + -p:ContainerRepository=nihlen/bf2-webadmin \ |
| 32 | + -p:ContainerImageTags=latest,sha-${{ github.sha }} \ |
| 33 | + -p:ContainerPush=true |
0 commit comments