Skip to content

🎨 Updates and misc improvements #2121

🎨 Updates and misc improvements

🎨 Updates and misc improvements #2121

Workflow file for this run

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@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
fetch-depth: 2
- uses: astral-sh/setup-uv@5a7eac68fb9809dea845d802897dc5c723910fa3 # v7
with:
enable-cache: true
- name: Generate build matrix
id: set-matrix
run: |
FORCE=$(if git log --pretty=format:"%s" HEAD^..HEAD | grep -q '\[force\]'; then echo "--force"; else echo ""; fi)
uv run dpn $FORCE build-matrix --event ${{ github.event_name }}
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:
# Setup
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- uses: astral-sh/setup-uv@5a7eac68fb9809dea845d802897dc5c723910fa3 # v7
with:
enable-cache: true
- name: Generate Dockerfile from config
run: uv run dpn dockerfile --context '${{ toJSON(matrix) }}'
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
- name: Login to Docker Hub
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build
- name: Build image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
with:
context: .
file: dockerfiles/${{ matrix.key }}.Dockerfile
load: true
tags: nikolaik/python-nodejs:${{ matrix.key }}
# Test
- 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"
# Push image
- name: Push image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
id: build-and-push
with:
context: .
file: dockerfiles/${{ matrix.key }}.Dockerfile
platforms: ${{ join(matrix.platforms) }}
push: true
tags: nikolaik/python-nodejs:${{ matrix.key }}
# Store build context
- name: Add digest to build context
run: |
mkdir builds/
digest="${{ steps.build-and-push.outputs.digest }}"
echo '${{ toJSON(matrix) }}' | jq --arg digest "$digest" '. +={"digest": $digest}' >> "builds/${{ matrix.key }}.json"
- name: Upload build context
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: build-${{ matrix.key }}
path: builds/*
if-no-files-found: error
retention-days: 1
release:
name: Update versions.json and README.md
runs-on: ubuntu-latest
needs: [deploy]
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- uses: astral-sh/setup-uv@5a7eac68fb9809dea845d802897dc5c723910fa3 # v7
with:
enable-cache: true
- name: Download metadata for builds
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
with:
path: builds
pattern: build-*
merge-multiple: true
- name: Update versions.json and README.md, then commit and push changes (if any)
run: |
uv run dpn --verbose release --builds-dir builds/
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