-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (94 loc) · 3.23 KB
/
blank.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# This is a basic workflow to help you get started with Actions
name: My build action requiring more space
on:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
APP_ID: 730
REMOTE_BUILDID: 0
TAG_EXISTS: 'false'
TAG: null
jobs:
build:
name: Build my artifact
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
tag: [slim]
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 4096
temp-reserve-mb: 2048
build-mount-path: '/var/lib/'
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
- name: Restart docker
run: sudo service docker restart
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
echo "Free space:"
df -h
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build (Dockerfile.buildid)
run: docker build -f Dockerfile.buildid -t remote-buildid:${{ env.APP_ID }} --build-arg APP_ID=${{ env.APP_ID }} .
- name: Find the Remote buildid
id: remote-buildid
run: |
REMOTE_BUILDID=$(docker run --rm remote-buildid:${{ env.APP_ID }})
echo "REMOTE_BUILDID=$REMOTE_BUILDID" >> $GITHUB_ENV
if [ "${{ matrix.tag }}" == "latest" ]; then
echo "TAG=${REMOTE_BUILDID}" >> $GITHUB_ENV
else
echo "TAG=${REMOTE_BUILDID}-${{ matrix.tag }}" >> $GITHUB_ENV
fi
- name: Remove Docker image
run: docker rmi remote-buildid:${{ env.APP_ID }}
- name: Check if tag exists
if: github.event_name != 'workflow_dispatch'
id: tag-exists
run: |
if docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}; then
echo "TAG_EXISTS=true" >> $GITHUB_ENV
fi
- name: Log in to the Container registry
if: env.TAG_EXISTS == 'false' || github.event_name == 'workflow_dispatch'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
if: env.TAG_EXISTS == 'false' || github.event_name == 'workflow_dispatch'
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.tag }}
type=raw,value=${{ env.TAG }}
- name: Build
run: |
echo "Free space:"
df -h
- name: Push Docker image
if: env.TAG_EXISTS == 'false' || github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@v6
with:
context: .
push: true
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
build-args: |
TAG=${{ matrix.tag }}
REMOTE_BUILDID=${{ env.REMOTE_BUILDID }}