Skip to content

CI

CI #591

Workflow file for this run

name: CI
on:
merge_group:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
- cron: '0 0 * * WED'
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up packer and dependencies
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install packer
packer init .pkr.hcl
pip install -r requirements.txt
- name: Build Base Image
uses: nick-fields/retry@v2
with:
max_attempts: 3
retry_on: error
timeout_minutes: 10
command: |
.bin/build-base.sh
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Base Image
run: |
docker push toolisticon/base-builder-image
build:
needs: [prepare]
name: Building ${{ matrix.image }} image
runs-on: ubuntu-latest
strategy:
matrix:
image:
[
'ansible',
'kube',
'java/openjdk11',
'java/openjdk17',
'java/openjdk21',
'nodejs',
'terraform',
]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up packer and dependencies
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install packer
packer init .pkr.hcl
pip install -r requirements.txt
- name: Build Image
uses: nick-fields/retry@v2
with:
max_attempts: 3
retry_on: error
timeout_minutes: 15
command: |
source ./.bin/_bash.inc
export entry=${{matrix.image}}
export folder=$(echo $entry | cut -d'/' -f1)
export image=$(echo $entry | cut -d'/' -f2)
prepareImage "${currentDir}/docker/${folder}"
buildImage "${currentDir}/docker/${folder}" "${image}.pkr.hcl"
- name: Login to Docker Hub
uses: docker/login-action@v3
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Release Image
if: github.ref == 'refs/heads/main'
run: |
source ./.bin/_bash.inc
export entry=${{matrix.image}}
export image=toolisticon/$(echo $entry | cut -d'/' -f2)-builder
docker tag ${image}:${IMAGE_TAG} ${image}:${MAJOR_DOCKER_TAG}
docker tag ${image}:${IMAGE_TAG} ${image}:${MINOR_DOCKER_TAG}
docker tag ${image}:${IMAGE_TAG} ${image}:latest
docker push ${image}:latest
docker push ${image}:${MAJOR_DOCKER_TAG}
docker push ${image}:${MINOR_DOCKER_TAG}
- name: Push Snaphot Image
if: github.ref == 'refs/heads/develop'
run: |
source ./.bin/_bash.inc
export entry=${{matrix.image}}
export image=toolisticon/$(echo $entry | cut -d'/' -f2)-builder
timeStamp=$(date +%s)
docker tag ${image}:${IMAGE_TAG} ${image}:${timeStamp}
docker push ${image}:${timeStamp}