Skip to content

Commit

Permalink
CI: publish docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Fovty committed Mar 13, 2024
1 parent 0c0553b commit cbc686f
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
name: Build Docker Image
name: Build and Push Docker Image

on:
push:
branches:
- main
tags:
- 'v*'
- '*'

jobs:
build:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(git rev-parse --short HEAD)
# Publish to DockerHUB. Necessary?
# - name: Log in to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Push Docker image
# run: docker push my-image-name:$(git rev-parse --short HEAD)
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}

- name: Extract tag name
id: tag_name
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}/kube-downscaler:${{ env.TAG_NAME }}

0 comments on commit cbc686f

Please sign in to comment.