forked from actions/runner-images
-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (31 loc) · 1.3 KB
/
build-ubuntu-22.04.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
name: Nightly Build Ubuntu 22.04 Image
on:
schedule:
- cron: '0 2 * * *' # Runs at 2 AM UTC every day
workflow_dispatch: # Allows manual triggering
jobs:
build-and-push:
runs-on: ubuntu-latest-8-cores
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Packer
uses: hashicorp/setup-packer@v3
- name: Initialize Packer
run: packer init images/ubuntu/templates/ubuntu-22.04.pkr.hcl
- name: Build Packer Image
run: packer build images/ubuntu/templates/ubuntu-22.04.pkr.hcl
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Image to GitHub Container Registry
run: |
IMAGE_NAME=$(jq -r '.builds[-1].artifact_id' manifest.json | cut -d ':' -f 2)
TIMESTAMP=$(date +%Y%m%d)
docker tag $IMAGE_NAME ghcr.io/${{ github.repository }}/ubuntu-22.04:nightly-$TIMESTAMP
docker tag $IMAGE_NAME ghcr.io/${{ github.repository }}/ubuntu-22.04:latest
docker push ghcr.io/${{ github.repository }}/ubuntu-22.04:nightly-$TIMESTAMP
docker push ghcr.io/${{ github.repository }}/ubuntu-22.04:latest