-
Notifications
You must be signed in to change notification settings - Fork 66
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
feat: add github action to publish workflow ui files #1027
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e64796f
feat: add github action to publish workflow ui files
estephinson 186a4a5
feat: change entirely how it works
estephinson c40ddb6
feat: change entirely how it works
estephinson a3af82b
chore: fix script
estephinson e9f1268
chore: fix path
estephinson 4c40040
fix: remove quotes form package
estephinson ae91314
fix: lets go
estephinson 8ec1e34
chore: fix body
estephinson 3b0ebbb
feat: support workflow in tests
estephinson 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,35 @@ | ||
name: Publish Workflow UI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- site/plugins.json | ||
jobs: | ||
sync-to-repo: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v3 | ||
- name: Using Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '*' | ||
cache: 'npm' | ||
check-latest: true | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Setup git config | ||
run: | | ||
git config user.name 'token-generator-app[bot]' | ||
git config user.email '82042599+token-generator-app[bot]@users.noreply.github.com' | ||
- name: Generate GitHub token | ||
uses: navikt/[email protected] | ||
id: get-token | ||
with: | ||
private-key: ${{ secrets.TOKENS_PRIVATE_KEY }} | ||
app-id: ${{ secrets.TOKENS_APP_ID }} | ||
- name: Upload Workflow UI files | ||
env: | ||
GITHUB_TOKEN: ${{ steps.get-token.outputs.token }} | ||
run: bin/publish_workflow_ui.sh |
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,34 @@ | ||
PR_TITLE="chore: publish workflow-ui files" | ||
BRANCH_NAME="publish_workflow_ui_$(date +%s)" | ||
|
||
git switch -c $BRANCH_NAME | ||
|
||
# install jq | ||
sudo apt-get install jq | ||
|
||
# Loop through each package, install from npm and copy the workflow-ui.json from root of the package if it exists | ||
cat site/plugins.json | jq ".[] | select(.workflow == true) | .package" | while read PACKAGE | ||
do | ||
echo "Installing $PACKAGE" | ||
# remove the quotes from the package name | ||
PACKAGE=$(echo $PACKAGE | tr -d '"') | ||
npm install $PACKAGE | ||
if [ -f "node_modules/$PACKAGE/workflow-ui.json" ]; then | ||
echo "Copying workflow-ui.json from $PACKAGE" | ||
cp node_modules/$PACKAGE/workflow-ui.json site/$PACKAGE/workflow-ui.json | ||
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. Not blocking but if you change this to |
||
fi | ||
done | ||
|
||
# Add all files to git in the site directory | ||
git add site | ||
|
||
# See if we have any changes. We should. | ||
if [[ -n "$(git status --porcelain)" ]]; then | ||
echo "Creating PR \"$PR_TITLE\" for branch $BRANCH_NAME" | ||
git commit -m "$PR_TITLE" | ||
git push origin $BRANCH_NAME | ||
gh pr create --title "$PR_TITLE" --body "This is an automated PR to publish workflow-ui" --label "workflow_ui" --label "automerge" | ||
else | ||
# Shouldn't end up here, but log that there was nothing to sync | ||
echo "Looks like there was nothing to sync." | ||
fi |
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
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.
Is there a reason to install the package vs pulling the file directly from NPM?
We only need raw files, not to pull dependencies and such
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.
nice, will use https://unpkg.com
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.
example being
now a package directory will be there with the file contents
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.
Suppose we'll need the whole package for the dynamic scripts and such
This is what I was using currently but I'll use
npm pack
instead