mirror of
https://github.com/nikolaik/docker-python-nodejs.git
synced 2025-09-05 23:27:57 +03:00
107 lines
3.6 KiB
YAML
107 lines
3.6 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
schedule:
|
|
- cron: "0 00,12 * * *" # Twice a day
|
|
|
|
jobs:
|
|
generate-matrix:
|
|
name: Generate build matrix
|
|
runs-on: ubuntu-latest
|
|
needs: [test]
|
|
outputs:
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version-file: '.python-version'
|
|
- name: Install uv
|
|
run: pip install -U uv
|
|
- name: Generate build matrix
|
|
run: |
|
|
FORCE=$(if git log --pretty=format:"%s" HEAD^..HEAD | grep -q '\[force\]'; then echo "--force"; else echo ""; fi)
|
|
uv run dpn --ci-matrix $FORCE --ci-event ${{ github.event_name }}
|
|
id: set-matrix
|
|
|
|
deploy:
|
|
name: ${{ matrix.key }}
|
|
runs-on: ubuntu-latest
|
|
if: needs.generate-matrix.outputs.matrix != ''
|
|
needs: [generate-matrix]
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version-file: '.python-version'
|
|
- name: Install uv
|
|
run: pip install -U uv
|
|
- name: Generate Dockerfile from config
|
|
run: uv run dpn --dockerfile-with-context '${{ toJSON(matrix) }}'
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
- name: Set up 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 image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: dockerfiles/${{ matrix.key }}.Dockerfile
|
|
load: true
|
|
tags: nikolaik/python-nodejs:${{ matrix.key }}
|
|
- name: Run smoke tests
|
|
run: |
|
|
docker run --rm nikolaik/python-nodejs:${{ matrix.key }} sh -c "node --version && npm --version && yarn --version && python --version && pip --version && pipenv --version && poetry --version && uv --version"
|
|
- name: Push image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: dockerfiles/${{ matrix.key }}.Dockerfile
|
|
platforms: ${{ join(matrix.platforms) }}
|
|
push: true
|
|
tags: nikolaik/python-nodejs:${{ matrix.key }}
|
|
|
|
release:
|
|
name: Update versions.json and README.md
|
|
runs-on: ubuntu-latest
|
|
needs: [deploy]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version-file: '.python-version'
|
|
- name: Install uv
|
|
run: pip install -U uv
|
|
- name: Update versions.json and README.md, then commit and push changes (if any)
|
|
run: |
|
|
uv run dpn --verbose --release
|
|
clean_checkout=$(git status --porcelain)
|
|
if [[ -n "${clean_checkout}" ]]; then
|
|
git config --global user.name "Nikolai Kristiansen" > /dev/null 2>&1
|
|
git config --global user.email nikolaik@users.noreply.github.com > /dev/null 2>&1
|
|
|
|
# Update README.md
|
|
today=$(date +%Y-%m-%d)
|
|
sed -i -E "s/Last updated by bot: .*/Last updated by bot: ${today}/" README.md
|
|
|
|
git add versions.json README.md
|
|
git commit -m '🗃 Updated python/node versions [skip ci]'
|
|
git push --quiet origin main
|
|
else
|
|
echo "Nothing changed, nothing to archive."
|
|
fi
|
|
|
|
test:
|
|
uses: ./.github/workflows/tests.yaml
|