Points bank (#20) #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/docker-image.yml | |
name: Build, Test, and Push Docker Image | |
on: | |
push: | |
branches: | |
- main | |
- 'prerelease-*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set repository name to lowercase | |
id: lowercase_repo | |
run: echo "REPO=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
- name: Determine Docker tag | |
id: get_tag | |
run: | | |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then | |
echo "tag=latest" >> $GITHUB_OUTPUT | |
elif [[ "${GITHUB_REF}" == refs/heads/prerelease-* ]]; then | |
echo "tag=prerelease" >> $GITHUB_OUTPUT | |
else | |
echo "tag=prerelease" >> $GITHUB_OUTPUT | |
fi | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Run tests | |
run: | | |
python -m unittest discover tests | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/${{ steps.lowercase_repo.outputs.REPO }}/tasks:${{ steps.get_tag.outputs.tag || 'prerelease' }} |