Skip to content

Commit

Permalink
Add workflow to autoupdate devcontainer.json version tags on new rele…
Browse files Browse the repository at this point in the history
…ase (autoatml#212)

* test

* demo test version change

* Update devcontainer.json with new version tag

* revert previous version change test

* Update devcontainer.json with new version tag

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
naik-aakash and github-actions authored Nov 10, 2024
1 parent e660c5c commit 376ba10
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/update_devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Update devcontainer.json on Release

on:
workflow_dispatch:
release:
types: [ created ] # Runs only when a new release is created

permissions:
contents: write # Allow the workflow to push changes to the repository

jobs:
update-version:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

# Run the script to update the version in devcontainer.json
- name: Update devcontainer.json with new version
run: |
#!/bin/bash
# Fetch the version from pyproject.toml
VERSION=$(grep 'version =' pyproject.toml | head -n 1 | sed -E 's/version = "([^\"]+)"/\1/')
# Debug the version extracted
echo "Extracted VERSION: $VERSION"
# Escape any special characters in VERSION that could cause issues with sed (like `/` or `:`)
VERSION_ESCAPED=$(echo "$VERSION" | sed 's/[&/\]/\\&/g')
# 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:$VERSION_ESCAPED|" .devcontainer/devcontainer.json
echo "Updated devcontainer.json with version $VERSION"
# Commit and push the changes to devcontainer.json
- name: Commit and push changes
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
# Get the current branch name
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $CURRENT_BRANCH"
git add .devcontainer/devcontainer.json
git commit -m "Update devcontainer.json with new version tag"
git push origin $CURRENT_BRANCH
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 376ba10

Please sign in to comment.