buildPacker
This commit is contained in:
@ -1,33 +1,28 @@
|
|||||||
name: Check Certificates Expiry
|
name: Build Ubuntu Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check_certs:
|
packer-build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Display certificate expiry dates
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Change to packer directory
|
||||||
|
working-directory: ./ubuntu-packer
|
||||||
run: |
|
run: |
|
||||||
for host in chosesoft.eu nas.chosesoft.eu gitea.chosesoft.eu; do
|
echo "Working dir: $(pwd)"
|
||||||
echo "🔍 Certificate for $host:"
|
ls -la
|
||||||
expiry_date=$(echo | openssl s_client -servername "$host" -connect "$host:443" 2>/dev/null \
|
|
||||||
| openssl x509 -noout -enddate | cut -d= -f2)
|
|
||||||
|
|
||||||
if [ -z "$expiry_date" ]; then
|
- name: Init Packer
|
||||||
echo "❌ Unable to fetch certificate for $host"
|
working-directory: ./ubuntu-packer
|
||||||
echo
|
run: |
|
||||||
continue
|
packer init .
|
||||||
fi
|
|
||||||
|
|
||||||
expiry_ts=$(date -d "$expiry_date" +%s)
|
- name: Build image
|
||||||
now_ts=$(date +%s)
|
working-directory: ./ubuntu-packer
|
||||||
|
run: |
|
||||||
if [ "$expiry_ts" -gt "$now_ts" ]; then
|
packer build ubuntu.pkr.hcl
|
||||||
echo "✅ Valid until: $expiry_date"
|
|
||||||
else
|
|
||||||
echo "❌ Expired on: $expiry_date"
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
done
|
|
Reference in New Issue
Block a user