-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add action to update vscode extension with latest version #394
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,58 @@ | ||
name: Update VSCode Extension | ||
|
||
description: 'Update the CLI version in vscode-extension' | ||
|
||
inputs: | ||
latest_tag: | ||
required: true | ||
description: 'The latest tag from the workflow that uses this action' | ||
access_token: | ||
required: true | ||
description: 'The access token to use for authentication' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: DevCycleHQ/vscode-extension | ||
path: vscode-extension | ||
token: ${{ inputs.access_token }} | ||
fetch-depth: 0 | ||
|
||
- name: Set Git author | ||
shell: bash | ||
working-directory: vscode-extension | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "DevCycle Automation" | ||
|
||
- name: Set branch name | ||
shell: bash | ||
working-directory: vscode-extension | ||
run: echo "BRANCH_NAME=update-cli-version-to-${{ inputs.latest_tag }}" >> $GITHUB_ENV | ||
|
||
- name: Update CLI version in vscode extension | ||
shell: bash | ||
working-directory: vscode-extension | ||
run: | | ||
# Remove 'v' prefix from latest_tag | ||
LATEST_TAG="${{ inputs.latest_tag }}" | ||
CLI_VERSION="${LATEST_TAG#v}" | ||
git checkout -b "$BRANCH_NAME" | ||
sed -i "s/export const CLI_VERSION = .*/export const CLI_VERSION = '${CLI_VERSION}' \/\/ auto updated by dvc cli release workflow/" src/constants.ts | ||
git add src/constants.ts | ||
git commit -m "Update CLI version to ${{ inputs.latest_tag }}" | ||
|
||
- name: Push code to extension repo | ||
shell: bash | ||
working-directory: vscode-extension | ||
run: git push --set-upstream origin "$BRANCH_NAME" | ||
|
||
- name: Create PR | ||
shell: bash | ||
working-directory: vscode-extension | ||
env: | ||
GH_TOKEN: ${{ inputs.access_token }} | ||
run: gh pr create --repo DevCycleHQ/vscode-extension --base main --head "$BRANCH_NAME" --title "Update CLI version to $LATEST_TAG" --body "This PR was automatically created by the DevCycle CLI release workflow." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Use inputs.latest_tag instead of $LATEST_TAG The variable |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider adding error handling for git push
Adding error handling for the
git push
command can help catch and handle any issues that might occur during the push operation, ensuring the workflow does not fail silently.