v0.0.9 #56
Workflow file for this run
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
name: Build and Push Docker Image | |
on: | |
workflow_dispatch: | |
release: | |
types: [ created ] # Runs only when a new release is created | |
jobs: | |
build-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
pull-requests: write | |
attestations: write | |
id-token: write | |
strategy: | |
matrix: | |
python-version: [ "3.10", "3.11", "3.12" ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: lowercase github.repository | |
run: | | |
echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV} | |
- name: Extract version from pyproject.toml | |
run: | | |
VERSION=$(grep '^version = ' pyproject.toml | sed -E 's/version = "(.*)"/\1/') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
# Build Docker image with a custom Python version | |
- name: Build Docker image (Python ${{ matrix.python-version }}) | |
run: | | |
docker build \ | |
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \ | |
-t ghcr.io/${{ env.IMAGE_NAME }}/autoplex-python-${{ matrix.python-version }}:${{ env.VERSION }} . | |
# Push Docker image to GHCR | |
- name: Push Docker image to GHCR (Python ${{ matrix.python-version }}) | |
run: | | |
docker push ghcr.io/${{ env.IMAGE_NAME }}/autoplex-python-${{ matrix.python-version }}:${{ env.VERSION }} | |
update-devcontainer: | |
if: github.event_name == 'release' && github.event.action == 'created' | |
needs: build-image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Update devcontainer.json with new version | |
run: | | |
TAG=$(curl -H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/orgs/autoatml/packages/container/autoplex%2Fautoplex-python-3.10/versions \ | |
| jq -r 'sort_by(.created_at) | reverse | .[0].metadata.container.tags[0]') | |
# Debug the version extracted | |
echo "Extracted TAG: $TAG" | |
# Update the version in devcontainer.json | |
# Using the escaped version to safely substitute in the JSON file | |
sed -i -E "s|ghcr.io/autoatml/autoplex/autoplex-python-3.10:[^\"]*|ghcr.io/autoatml/autoplex/autoplex-python-3.10:$TAG|" .devcontainer/devcontainer.json | |
echo "Updated devcontainer.json with version $TAG" | |
- name: Create Pull Request to push updated devcontainer | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.ACTION_SECRET }} | |
commit-message: update devcontainer | |
title: Update devcontainer.json version tag | |
body: Update devcontainer.json version tag to reflect release changes | |
branch: update-devcontainer | |
delete-branch: true | |
base: main |