-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (59 loc) · 1.98 KB
/
spuc-build-test-push.yaml
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
65
66
67
68
69
70
name: SPUC-build-test-push
on:
workflow_dispatch:
inputs:
version:
description: 'Push with versioned tag?'
required: false
type: string
default: ''
push:
branches: [ "main" ]
paths:
- 'code/SPUC/Dockerfile'
- '.github/workflows/spuc-build-test-push.yaml'
jobs:
build-push:
runs-on: ubuntu-latest
env:
CONTAINER_NAME: spuc
CONTEXT: ./code/SPUC
DOCKERFILE: ./code/SPUC/Dockerfile
README: ./code/SPUC/README.md
# -------------------------------------------------------------------------------- #
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set tag
id: set-tag
run: |
IMAGE_REPO="${{ secrets.DOCKERHUB_USER }}/${{ env.CONTAINER_NAME }}"
if [ -z "${{ github.event.inputs.version }}" ]; then
echo "tags=${IMAGE_REPO}:latest" >> $GITHUB_OUTPUT
else
echo "tags=${IMAGE_REPO}:${{ github.event.inputs.version }},${IMAGE_REPO}:latest" >> $GITHUB_OUTPUT
fi
- name: Build and push to dockerhub
uses: docker/build-push-action@v5
with:
context: ${{ env.CONTEXT }}
file: ${{ env.DOCKERFILE }}
tags: ${{ steps.set-tag.outputs.tags }}
cache-from: type=gha,scope=${{ env.CONTAINER_NAME }}
cache-to: type=gha,scope=${{ env.CONTAINER_NAME }},mode=max
push: true
- name: Update description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ secrets.DOCKERHUB_USER }}/${{ env.CONTAINER_NAME }}
readme-filepath: ${{ env.README }}
enable-url-completion: true