forked from autoatml/autoplex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to autoupdate devcontainer.json version tags on new rele…
…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
1 parent
e660c5c
commit 376ba10
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
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 }} |