-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (38 loc) · 1.27 KB
/
build-deploy.yaml
File metadata and controls
45 lines (38 loc) · 1.27 KB
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
name: Docker Build and Deploy Image
on:
workflow_dispatch:
push:
tags:
- 'v*.*.*'
jobs:
deploy:
name: Build and Deploy Image
runs-on: ubuntu-latest
env:
DOCKER_REPO_NAME: binarypatrick/header-audit
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Extract tag name
run: echo "TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Set Release Tag Variables
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
echo "DOCKER_IMAGE_TAGS=$DOCKER_REPO_NAME:${GITHUB_REF#refs/tags/v}, $DOCKER_REPO_NAME:latest" >> "$GITHUB_ENV"
- name: Set Prerelease Tag Variables
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
run: |
echo "DOCKER_IMAGE_TAGS=$DOCKER_REPO_NAME:${{ github.sha }}, $DOCKER_REPO_NAME:prerelease" >> "$GITHUB_ENV"
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and Push
uses: docker/build-push-action@v4
with:
context: ./src
push: true
tags: ${{ env.DOCKER_IMAGE_TAGS }}
build-args: |
GIT_TAG=${{ env.TAG }}