File size: 2,464 Bytes
535f873 0535e92 c2ae771 0535e92 fc14950 0535e92 fc14950 0535e92 fc14950 0535e92 fc14950 ab6e058 535f873 31fa10f c2ae771 13a1a61 32f4b84 13a1a61 c34a2a5 9871835 13a1a61 535f873 8866240 535f873 c2ae771 31fa10f c6cc6a0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
name: Docker Build and Publish Docker Image
on:
push:
branches:
- main
paths:
- VERSION
- main.py
- utils.py
- models.py
- request.py
- Dockerfile
- response.py
- .dockerignore
- requirements.txt
- docker-compose.yml
- .github/workflows/main.yml
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PACK_TOKEN }}
- name: Get current version
id: get_version
run: |
VERSION=$(cat VERSION || echo "0.0.0")
echo "Current version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Bump version
id: bump_version
run: |
IFS='.' read -ra VERSION_PARTS <<< "${{ steps.get_version.outputs.version }}"
PATCH=$((VERSION_PARTS[2] + 1))
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$PATCH"
echo $NEW_VERSION > VERSION
echo "New version: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Commit version bump
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add VERSION
git commit -m "📖 Bump version to ${{ steps.bump_version.outputs.new_version }}"
git push
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
yym68686/uni-api:latest
yym68686/uni-api:${{ steps.bump_version.outputs.new_version }}
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ steps.bump_version.outputs.new_version }} |