-
Notifications
You must be signed in to change notification settings - Fork 8
58 lines (46 loc) · 1.59 KB
/
dockerImagePublish.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
54
55
56
57
58
name: Docker Image Publish
on:
release:
types: [published]
env:
IMAGE_NAME: build
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Free additional disk space
run: |
echo "Initial free space: "
df -h /
sudo rm -rf /usr/local/lib/android
echo "Removed Android SDK: "
df -h /
sudo rm -rf /usr/share/dotnet
echo "Removed .NET runtime: "
df -h /
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "Tool cache cleanup: "
df -h /
sudo docker image prune --all --force
echo "Docker prune: "
df -h /
sudo apt remove -y '^llvm-.*-dev$' '^dotnet-.*' '^openjdk-.*' '.*-jdk$' firefox google-chrome-stable microsoft-edge-stable google-cloud-cli azure-cli mono-devel powershell
sudo apt autoremove -y
sudo apt clean
echo "Package cleanup: "
df -h /
- uses: actions/checkout@v4
- name: Build the container image
run: podman build . --file Dockerfile --tag image --squash-all
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
# Image ID must be lowercase
IMAGE_ID=ghcr.io/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')/$IMAGE_NAME
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
podman tag image $IMAGE_ID:$VERSION
podman push $IMAGE_ID:$VERSION