mirror of
https://github.com/craigerl/aprsd.git
synced 2026-02-25 02:30:05 -05:00
85 lines
2.2 KiB
YAML
85 lines
2.2 KiB
YAML
name: Test and Build Latest Container Image
|
||
|
||
on:
|
||
schedule:
|
||
- cron: "0 10 * * *"
|
||
push:
|
||
branches:
|
||
- "**"
|
||
tags:
|
||
- "*.*.*"
|
||
pull_request:
|
||
branches:
|
||
- "master"
|
||
|
||
jobs:
|
||
tox:
|
||
runs-on: ubuntu-latest
|
||
strategy:
|
||
matrix:
|
||
python-version: ["3.11"]
|
||
steps:
|
||
- uses: actions/checkout@v2
|
||
- name: Set up Python ${{ matrix.python-version }}
|
||
uses: actions/setup-python@v2
|
||
with:
|
||
python-version: ${{ matrix.python-version }}
|
||
- name: Install dependencies
|
||
run: |
|
||
python -m pip install --upgrade pip
|
||
pip install tox tox-gh>=1.2
|
||
- name: Test with tox
|
||
run: tox
|
||
|
||
build:
|
||
needs: tox
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
- name: Get Branch Name
|
||
id: branch-name
|
||
uses: tj-actions/branch-names@v8
|
||
- name: Resolve Docker Tag
|
||
id: docker-tag
|
||
env:
|
||
BRANCH_NAME: ${{ steps.branch-name.outputs.current_branch }}
|
||
run: |
|
||
#!/bin/bash
|
||
branch="${BRANCH_NAME}"
|
||
|
||
# If branch is empty, use 'master' as fallback
|
||
if [ -z "$branch" ]; then
|
||
echo "Branch is empty, using 'master'"
|
||
tag="master"
|
||
else
|
||
# Sanitize branch name for Docker tag (replace / with -)
|
||
tag="${branch//\//-}"
|
||
echo "Using sanitized branch: $tag"
|
||
fi
|
||
|
||
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
|
||
echo "Docker tag will be: ${tag}"
|
||
- name: Setup QEMU
|
||
uses: docker/setup-qemu-action@v3
|
||
- name: Setup Docker Buildx
|
||
uses: docker/setup-buildx-action@v3
|
||
- name: Login to Docker HUB
|
||
uses: docker/login-action@v3
|
||
with:
|
||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||
- name: Build the Docker image
|
||
uses: docker/build-push-action@v6
|
||
with:
|
||
context: "{{defaultContext}}:docker"
|
||
platforms: linux/amd64,linux/arm64
|
||
file: ./Dockerfile
|
||
build-args: |
|
||
INSTALL_TYPE=github
|
||
BRANCH=${{ steps.docker-tag.outputs.tag }}
|
||
BUILDX_QEMU_ENV=true
|
||
push: true
|
||
tags: |
|
||
hemna6969/aprsd:${{ steps.docker-tag.outputs.tag }}
|