Skip to content

cleanup of generic board #170

cleanup of generic board

cleanup of generic board #170

Workflow file for this run

name: PI-CI
on:
push:
branches:
- '**'
env:
IMAGE_NAME: ptrsr/pi-ci
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Free up disk space on github runner
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
# android: false
# dotnet: false
# haskell: false
# large-packages: false
# swap-storage: false
- name: Checkout
uses: actions/checkout@v4
- name: Cache register
id: cache
uses: actions/cache@v4
with:
path: /tmp/image.tar
key: ${{ hashFiles('dockerfile') }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
docker buildx build \
-t ${{ env.IMAGE_NAME }} \
-o type=docker,dest=- \
. > /tmp/image.tar
test:
needs: build
runs-on: ubuntu-22.04
outputs:
publish: ${{ steps.check.outputs.publish }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache register
id: cache
uses: actions/cache@v4
with:
path: /tmp/image.tar
key: ${{ hashFiles('dockerfile') }}
- name: Load Docker image
run: docker load -i /tmp/image.tar
- name: Install dependencies
run: |
sudo apt-get install ansible
pip3 install docker-py
- name: Run test
run: |
ansible-playbook \
-i test/hosts.yml \
test/main.yml
- uses: actions/upload-artifact@v4
with:
name: config
path: dist
- name: Check for Tag
id: check
run: |
git fetch --tags
if [[ ! -z "$(git tag --contains HEAD)" ]]; then
echo "publish=true" >> $GITHUB_OUTPUT
fi
publish:
if: needs.test.outputs.publish == 'true'
needs: test
runs-on: ubuntu-22.04
environment: docker-hub
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set tag variable
run: |
git fetch --tags
echo "TAG=$(git tag --contains HEAD)" >> $GITHUB_ENV
- name: Cache register
id: cache
uses: actions/cache@v4
with:
path: /tmp/image.tar
key: ${{ hashFiles('dockerfile') }}
- name: Load Docker image
run: docker load -i /tmp/image.tar
- name: Tag docker image
run: docker tag ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:${{ env.TAG }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push to Docker Hub
run: docker push -a ${{ env.IMAGE_NAME }}