Skip to content

Commit a1783be

Browse files
author
Mirko Brombin
authored
Initial commit
0 parents  commit a1783be

File tree

14 files changed

+1081
-0
lines changed

14 files changed

+1081
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ref: https://git-scm.com/docs/gitattributes
2+
* text=auto eol=lf

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
9+
env:
10+
REGISTRY_USER: ${{ github.actor }}
11+
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write # Allow actions to create release
18+
attestations: write # To create and write attestations
19+
id-token: write # Additional permissions for the persistence of the attestations
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- uses: vanilla-os/vib-gh-action@v0.8.1
28+
with:
29+
recipe: 'recipe.yml'
30+
plugins: 'Vanilla-OS/vib-fsguard:v1.5.3'
31+
32+
- uses: actions/upload-artifact@v4
33+
with:
34+
name: Containerfile
35+
path: Containerfile
36+
37+
- name: Create Release
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
run: gh release create "${{ github.ref_name }}" --generate-notes Containerfile
41+
42+
- name: Attest Release Files
43+
id: attest
44+
uses: actions/attest-build-provenance@v1
45+
with:
46+
subject-path: 'Containerfile'

.github/workflows/vib-build.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Vib Build
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
tags:
7+
- '*'
8+
schedule:
9+
- cron: '21 */6 * * *'
10+
pull_request:
11+
workflow_dispatch:
12+
13+
env:
14+
CUSTOM_IMAGE_NAME: custom
15+
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
16+
17+
jobs:
18+
check_update:
19+
runs-on: ubuntu-latest
20+
21+
outputs:
22+
has_updates: ${{ steps.set_output.outputs.has_updates }}
23+
base_image: ${{ steps.read_base_recipe.outputs.base_image }}
24+
25+
permissions:
26+
contents: write # Allow actions to create a digest
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Install dependencies
33+
run: sudo apt-get install -y jq skopeo libfyaml-utils
34+
35+
- name: Read base image name from recipe
36+
id: read_base_recipe
37+
run: |
38+
BASE_IMAGE="$(fy-filter -f recipe.yml /stages/-1/base)"
39+
echo The base image is $BASE_IMAGE
40+
if [ -z $BASE_IMAGE ]; then exit 1; fi
41+
echo "base_image=$BASE_IMAGE" >> "$GITHUB_OUTPUT"
42+
echo "BASE_IMAGE=$BASE_IMAGE" >> "$GITHUB_ENV"
43+
44+
- name: Get last successful run
45+
if: ${{ github.ref_type == 'branch' }}
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
continue-on-error: true
49+
run: |
50+
gh run list -b "${{ github.ref_name }}" -w "${{ github.workflow }}" -s "success" -L 1 --json databaseId > last_run.json
51+
echo "LAST_RUN_ID=$(jq -r '.[0].databaseId' last_run.json)" >> "$GITHUB_ENV"
52+
53+
- name: Download the previous digest
54+
uses: actions/download-artifact@v4
55+
continue-on-error: true
56+
with:
57+
name: digest
58+
github-token: ${{ github.token }}
59+
run-id: ${{ env.LAST_RUN_ID }}
60+
61+
- name: Check if there was an update to the base image
62+
run: |
63+
touch digest.txt
64+
mv digest.txt last_digest.txt
65+
skopeo inspect --raw docker://${{ env.BASE_IMAGE }} | sha256sum > digest.txt
66+
echo Old digest is: $(cat last_digest.txt)
67+
echo New digest is: $(cat digest.txt)
68+
echo "HAS_UPDATES=$(cmp -s digest.txt last_digest.txt; echo $?)" >> "$GITHUB_ENV"
69+
70+
- name: Upload current digest
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: digest
74+
path: digest.txt
75+
76+
- name: Set output
77+
id: set_output
78+
run: |
79+
if [ ${{ github.event_name == 'schedule'}} == false ]
80+
then
81+
echo action was manually run, updating either way
82+
echo "has_updates=true" >> "$GITHUB_OUTPUT"
83+
elif [ ${{ env.HAS_UPDATES }} == 1 ]
84+
then
85+
echo base image was updated since the last build
86+
echo "has_updates=true" >> "$GITHUB_OUTPUT"
87+
else
88+
echo no updates to the base image since the last build
89+
echo "has_updates=false" >> "$GITHUB_OUTPUT"
90+
fi
91+
92+
build:
93+
runs-on: ubuntu-latest
94+
needs: check_update
95+
if: ${{ needs.check_update.outputs.has_updates == 'true' }}
96+
97+
permissions:
98+
packages: write # Allow pushing images to GHCR
99+
attestations: write # To create and write attestations
100+
id-token: write # Additional permissions for the persistence of the attestations
101+
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- uses: vanilla-os/vib-gh-action@v0.8.1
106+
with:
107+
recipe: 'recipe.yml'
108+
plugins: 'Vanilla-OS/vib-fsguard:v1.5.3'
109+
110+
- uses: actions/upload-artifact@v4
111+
with:
112+
name: Containerfile
113+
path: Containerfile
114+
115+
- name: Generate image name
116+
run: |
117+
REPO_OWNER_LOWERCASE="$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')"
118+
echo "REPO_OWNER_LOWERCASE=$REPO_OWNER_LOWERCASE">> "$GITHUB_ENV"
119+
echo "IMAGE_URL=ghcr.io/$REPO_OWNER_LOWERCASE/${{ env.CUSTOM_IMAGE_NAME }}">> "$GITHUB_ENV"
120+
121+
- name: Set image info
122+
run: |
123+
echo -n "${{ needs.check_update.outputs.base_image }}" > ./includes.container/image-info/base-image-name
124+
echo -n "${{ env.REPO_OWNER_LOWERCASE }}/${{ env.CUSTOM_IMAGE_NAME }}" > ./includes.container/image-info/image-name
125+
126+
- name: Docker meta
127+
id: docker_meta
128+
uses: docker/metadata-action@v5
129+
with:
130+
images: |
131+
${{ env. IMAGE_URL }}
132+
tags: |
133+
type=semver,pattern={{version}}
134+
type=semver,pattern={{major}}.{{minor}}
135+
type=semver,pattern={{raw}}
136+
type=semver,pattern=v{{major}}
137+
type=ref,event=branch
138+
139+
- name: Set up Docker Buildx
140+
uses: docker/setup-buildx-action@v3
141+
142+
- name: Login to GitHub Package Registry
143+
uses: docker/login-action@v3
144+
if: ${{ github.event_name != 'pull_request' }}
145+
with:
146+
registry: ghcr.io
147+
username: ${{ github.repository_owner }}
148+
password: ${{ secrets.GITHUB_TOKEN }}
149+
150+
- name: Build and Push the Docker image
151+
id: push
152+
uses: docker/build-push-action@v6
153+
with:
154+
context: .
155+
file: Containerfile
156+
push: ${{ github.event_name != 'pull_request' }}
157+
tags: ${{ steps.docker_meta.outputs.tags }}
158+
labels: ${{ steps.docker_meta.outputs.labels }}
159+
cache-from: type=gha
160+
cache-to: type=gha,mode=max
161+
platforms: linux/amd64
162+
provenance: false
163+
164+
- name: Attest pushed image
165+
uses: actions/attest-build-provenance@v1
166+
id: attest
167+
if: ${{ github.event_name != 'pull_request' }}
168+
with:
169+
subject-name: ${{ env.IMAGE_URL }}
170+
subject-digest: ${{ steps.push.outputs.digest }}
171+
push-to-registry: false

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Vib directories
2+
Containerfile
3+
downloads/
4+
plugins/
5+
sources/

0 commit comments

Comments
 (0)