Skip to content

Commit

Permalink
add CI so i can get this moved into kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
cschmittiey authored Mar 15, 2024
1 parent 672dccd commit 2b6f4e8
Showing 1 changed file with 49 additions and 7 deletions.
56 changes: 49 additions & 7 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,59 @@ name: Docker Image CI

on:
push:
branches: [ "main" ]
branches: ['main']
pull_request:
branches: [ "main" ]

jobs:
concurrency:
group: '${{ github.workflow }} @ ${{ github.ref }}'
cancel-in-progress: true

build:
env:
REGISTRY: ghcr.io
BASE_IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-base-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Containerfile --tag ha-discord-mute-sensor:$(date +%s)
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}

- name: Build and push Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
file: Containerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build Docker image
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 2b6f4e8

Please sign in to comment.