Skip to content

Commit cbc686f

Browse files
committed
CI: publish docker image
1 parent 0c0553b commit cbc686f

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

.github/workflows/docker-build.yml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
1-
name: Build Docker Image
1+
name: Build and Push Docker Image
22

33
on:
44
push:
55
branches:
66
- main
77
tags:
8-
- 'v*'
8+
- '*'
99

1010
jobs:
11-
build:
11+
docker:
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
1317
steps:
14-
- uses: actions/checkout@v2
15-
- name: Build Docker image
16-
run: docker build . --file Dockerfile --tag my-image-name:$(git rev-parse --short HEAD)
17-
# Publish to DockerHUB. Necessary?
18-
# - name: Log in to DockerHub
19-
# uses: docker/login-action@v1
20-
# with:
21-
# username: ${{ secrets.DOCKER_USERNAME }}
22-
# password: ${{ secrets.DOCKER_PASSWORD }}
23-
# - name: Push Docker image
24-
# run: docker push my-image-name:$(git rev-parse --short HEAD)
18+
- name: Check out the repo
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Log in to GitHub Container Registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.repository_owner }}
29+
password: ${{ secrets.CR_PAT }}
30+
31+
- name: Extract tag name
32+
id: tag_name
33+
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
34+
35+
- name: Build and push Docker image
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: .
39+
file: ./Dockerfile
40+
push: true
41+
tags: ghcr.io/${{ github.repository }}/kube-downscaler:${{ env.TAG_NAME }}

0 commit comments

Comments
 (0)