-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add github action to publish workflow ui files (#1027)
* feat: add github action to publish workflow ui files * feat: change entirely how it works * feat: change entirely how it works * chore: fix script * chore: fix path * fix: remove quotes form package * fix: lets go * chore: fix body * feat: support workflow in tests
- Loading branch information
1 parent
6799f0d
commit 9eea77d
Showing
3 changed files
with
78 additions
and
3 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,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 | ||
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