Skip to content

1.12.0: Update Python, fix rare reference error, add debug #23

1.12.0: Update Python, fix rare reference error, add debug

1.12.0: Update Python, fix rare reference error, add debug #23

Workflow file for this run

name: Build
on:
release:
types: [published]
jobs:
test:
name: Docker Test on ubuntu-latest
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
driver-opts: network=host
- name: Update Version String
run: |
sed -i -r 's/VERSION = "custom"/VERSION = "0.0+test"/' pyouroboros/__init__.py
echo $?\
- name: Build Docker
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
cache-from: type=gha,scope=main
cache-to: type=gha,mode=max,scope=main
tags: localhost:5000/tester/ouroboros:test
- name: Test with Docker
run: |
sudo mkdir -p /app/pyouroboros/hooks
docker run --rm --name ouroboros -v /var/run/docker.sock:/var/run/docker.sock localhost:5000/tester/ouroboros:test --run-once --dry-run --log-level debug
build:
name: Docker Build on ubuntu-latest
runs-on: ubuntu-latest
needs: test
steps:
- name: Check Credentials
id: check_credentials
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_CLITOKEN: ${{ secrets.DOCKER_CLITOKEN }}
run: |
if [ "${DOCKER_USER}" == "" ]; then
echo "Missing User"
echo "missingsecrets=yes" >> $GITHUB_OUTPUT
elif [ "${DOCKER_CLITOKEN}" == "" ]; then
echo "Missing Cli Token"
echo "missingsecrets=yes" >> $GITHUB_OUTPUT
else
echo "All secrets present"
echo "missingsecrets=no" >> $GITHUB_OUTPUT
fi
- name: Checkout Repository
if: contains(steps.check_credentials.outputs.missingsecrets, 'no')
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get Revision Variables
id: build_env
run: |
echo ${GITHUB_REF:10}
echo "branch=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
- name: Set up QEMU
if: contains(steps.check_credentials.outputs.missingsecrets, 'no')
uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64,arm
- name: Set up Docker Buildx
if: contains(steps.check_credentials.outputs.missingsecrets, 'no')
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Login to DockerHub Registry
if: contains(steps.check_credentials.outputs.missingsecrets, 'no')
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_CLITOKEN }}
logout: true
- name: Login to GitHub Container Registry
if: contains(steps.check_credentials.outputs.missingsecrets, 'no')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: true
- name: Update Version String
if: contains(steps.check_credentials.outputs.missingsecrets, 'no')
env:
OUROBOROS_VERSION: ${{ steps.build_env.outputs.branch }}
run: |
sed -i -r 's/VERSION = "custom"/VERSION = "'$OUROBOROS_VERSION'"/' pyouroboros/__init__.py
echo $?\
- name: Build and Push Docker
if: contains(steps.check_credentials.outputs.missingsecrets, 'no')
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
cache-from: type=gha,scope=main
cache-to: type=gha,mode=max,scope=main
tags: |
${{ secrets.DOCKER_USER }}/ouroboros:${{ steps.build_env.outputs.branch }}
${{ secrets.DOCKER_USER }}/ouroboros:latest
ghcr.io/${{ github.repository_owner }}/ouroboros:${{ steps.build_env.outputs.branch }}
ghcr.io/${{ github.repository_owner }}/ouroboros:latest
cleanup:
name: Cleanup Cache
runs-on: ubuntu-latest
needs: [test, build]
steps:
- name: Cleanup Cache
run: |
gh extension install actions/gh-actions-cache
REPO="${{ github.repository }}"
BRANCH="${{ github.ref }}"
echo "Fetching list of cache keys"
cacheKeys=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeys
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}