-
Notifications
You must be signed in to change notification settings - Fork 1
47 lines (45 loc) · 1.56 KB
/
cd.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
---
name: CD
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: bdossantos
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Dockefile build context, image name and tags
shell: bash
id: context
run: |
version=$(egrep ' VERSION=(.*)$' 'Dockerfile' | sed 's/^.*=//')
vcs_ref=$(git rev-parse --short HEAD)
image_name='home-assistant'
tags=bdossantos/${image_name}:latest,bdossantos/${image_name}:${version},bdossantos/${image_name}:${version}-${vcs_ref}
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
echo "path=$(dirname ${{ inputs.dockerfile }})" >> $GITHUB_OUTPUT
echo "tags=${tags}" >> $GITHUB_OUTPUT
echo "vcs_ref=${vcs_ref}" >> $GITHUB_OUTPUT
- name: Build and push docker image
uses: docker/build-push-action@v6
with:
build-args: |
BUILD_DATE=${{ steps.context.outputs.build_date }}
VCS_REF=${{ steps.context.outputs.vcs_ref }}
context: ${{ steps.context.outputs.path }}
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.context.outputs.tags }}