-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (67 loc) · 2.44 KB
/
Copy pathbuild-image.yml
File metadata and controls
78 lines (67 loc) · 2.44 KB
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
name: Build e Push da Imagem Bootc
on:
schedule:
- cron: '0 5 * * *'
push:
branches:
- main
paths-ignore:
- 'README.md'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ferlinuxdebian/sway-bootc
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout do código
uses: actions/checkout@v4
- name: Liberar espaço em disco
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc \
"/usr/local/share/boost" "$AGENT_TOOLSDIRECTORY"
- name: Gerar metadados do build
id: meta
run: |
VERSION=$(grep '^FROM' Containerfile | head -n 1 | awk -F: '{print $2}' | awk '{print $1}')
DATE=$(TZ='America/Sao_Paulo' date +'%Y%m%d-%H%M')
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
PRIMARY="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-${DATE}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "date=${DATE}" >> $GITHUB_OUTPUT
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "primary=${PRIMARY}" >> $GITHUB_OUTPUT
- name: Login no GHCR
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | buildah login \
-u "${{ github.actor }}" --password-stdin "${{ env.REGISTRY }}"
- name: Build da imagem
run: |
buildah build \
--skip-unused-stages=false \
--security-opt label=disable \
-t "${{ steps.meta.outputs.primary }}" \
-f Containerfile \
-v "$(pwd):/run/src" \
.
- name: Push da tag principal
run: buildah push "${{ steps.meta.outputs.primary }}"
- name: Aplicar tags adicionais via skopeo
run: |
VERSION="${{ steps.meta.outputs.version }}"
SHORT_SHA="${{ steps.meta.outputs.short_sha }}"
BASE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
CREDS="${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}"
for TAG in "${VERSION}-latest" "latest" "main" "sha-${SHORT_SHA}"; do
echo "→ Copiando manifesto para :${TAG}"
skopeo copy \
--src-creds "${CREDS}" \
--dest-creds "${CREDS}" \
"docker://${{ steps.meta.outputs.primary }}" \
"docker://${BASE}:${TAG}"
done