Skip to content

Nightly Build Ubuntu 22.04 Image #6

Nightly Build Ubuntu 22.04 Image

Nightly Build Ubuntu 22.04 Image #6

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