-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (43 loc) · 1.32 KB
/
push-docker-image.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
48
49
50
51
52
53
name: Create and publish a Docker image
on:
push:
branches: ['main']
env:
REGISTRY: ghcr.io
REPO_NAME: ${{ github.repository }}
DOCKER_SLIM_VERSION: 1.40.11
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set docker image env var
run: |
echo "IMAGE_NAME=${{ env.REGISTRY }}/${{ env.REPO_NAME }}:${{ env.DOCKER_SLIM_VERSION }}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
"DOCKER_SLIM_VERSION=${{ env.DOCKER_SLIM_VERSION }}"
push: true
tags: ${{ env.IMAGE_NAME }}
- name: Make a Slim image
uses: kitabisa/docker-slim-action@v1
env:
DSLIM_HTTP_PROBE: false
with:
target: ${{ env.IMAGE_NAME }}
tag: "${{ env.DOCKER_SLIM_VERSION }}-slim"
# Push to the registry
- run: docker push ${{ env.IMAGE_NAME }}-slim