Skip to content

Commit

Permalink
Merge pull request #8 from SlateFoundation/develop
Browse files Browse the repository at this point in the history
Release: v1.0.0
  • Loading branch information
themightychris authored Oct 17, 2021
2 parents 1f72d3a + d1b3257 commit 8001e97
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 28 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/release-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Release: Deploy PR'

on:
pull_request:
branches: [ master ]
types: [ closed ]

jobs:
release-deploy:
if: github.event.pull_request.merged == true # only run on PR merge
runs-on: ubuntu-latest
steps:

- name: Configure release
run: |
PR_TITLE=$(jq -r ".pull_request.title" $GITHUB_EVENT_PATH)
PR_BODY=$(jq -r ".pull_request.body" $GITHUB_EVENT_PATH)
RELEASE_TAG=$(echo "${PR_TITLE}" | grep -oP "(?<=^Release: )v\d+\.\d+\.\d+(-rc\.\d+)?$")
if [[ "${RELEASE_TAG}" =~ -rc\.[0-9]+$ ]]; then
RELEASE_PRERELEASE=true
else
RELEASE_PRERELEASE=false
fi
echo "PR_TITLE=${PR_TITLE}" >> $GITHUB_ENV
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV
echo "RELEASE_PRERELEASE=${RELEASE_PRERELEASE}" >> $GITHUB_ENV
echo 'PR_BODY<<END_OF_PR_BODY' >> $GITHUB_ENV
echo "${PR_BODY}" >> $GITHUB_ENV
echo 'END_OF_PR_BODY' >> $GITHUB_ENV
- name: Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
commit: '${{ github.sha }}'
tag: '${{ env.RELEASE_TAG }}'
body: '${{ env.PR_BODY }}'
draft: false
prerelease: ${{ env.RELEASE_PRERELEASE }}
113 changes: 113 additions & 0 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: 'Release: Prepare PR'

on:
push:
branches: [ develop ]

env:
GITHUB_USERNAME: jarvus-bot
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
RELEASE_BRANCH: master

jobs:
release-prepare:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2
with:
fetch-depth: 0

# - uses: mxschmitt/action-tmate@v3

- name: Create/update pull request
run: |
# get latest release tag
latest_release=$(git describe --tags --abbrev=0 "origin/${RELEASE_BRANCH}")
latest_release_bumped=$(echo $latest_release | awk -F. -v OFS=. '{$NF++;print}')
# create or update PR
pr_body="$(cat <<EOF
Release: ${latest_release_bumped}
## Improvements
## Technical
EOF
)"
pr_number=$(hub pr list -h develop -f '%I')
if [ -n "${pr_number}" ]; then
echo "Updating PR #${pr_number}"
existing_comment_id=$(hub api "/repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" | jq ".[] | select(.user.login==\"${GITHUB_USERNAME}\") | .id")
else
echo "Opening PR"
hub pull-request -b "${RELEASE_BRANCH}" -h develop -F <(echo "${pr_body}") > /tmp/pr.json
pr_number=$(hub pr list -h develop -f '%I')
echo "Opened PR #${pr_number}"
fi
# build changelog
commits=$(
git log \
--first-parent \
--reverse \
--format="%H" \
"origin/${RELEASE_BRANCH}..develop"
)
changelog=()
while read -r commit; do
subject="$(git show -s --format=%s "${commit}")"
line=""
if [[ "${subject}" =~ Merge\ pull\ request\ \#([0-9]+) ]]; then
line="$(hub pr show -f '%t [%i] @%au' "${BASH_REMATCH[1]}" || true)"
fi
if [ -z "${line}" ]; then
author="$(hub api "/repos/${GITHUB_REPOSITORY}/commits/${commit}" -H Accept:application/vnd.github.v3+json | jq -r '.author.login')"
if [ -n "${author}" ]; then
author="@${author}"
else
author="$(git show -s --format=%ae "${commit}")"
fi
line="${subject} ${author}"
fi
# move ticket number prefix into to existing square brackets at end
line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*\[([^]]+)\]\s*(\S+)$/\2 [\3, \1] \4/')"
# move ticket number prefix into to new square brackets at end
line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*(\S+)$/\2 [\1] \3/')"
# combine doubled square brackets at the end
line="$(echo "${line}" | perl -pe 's/^\s*(.*?)\s*\[([A-Z]+-[0-9]+)\]\s*\[([^]]+)\]\s*(\S+)$/\1 [\3, \2] \4/')"
changelog+=("- ${line}")
done <<< "${commits}"
# create or update comment
comment_body="$(cat <<EOF
## Changelog
\`\`\`markdown
$(IFS=$'\n'; echo "${changelog[*]}")
\`\`\`
EOF
)"
if [ -n "${existing_comment_id}" ]; then
echo "Updating comment #${existing_comment_id}"
hub api "/repos/${GITHUB_REPOSITORY}/issues/comments/${existing_comment_id}" -f body="${comment_body}"
else
echo "Creating comment"
hub api "/repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" -f body="${comment_body}"
fi
33 changes: 33 additions & 0 deletions .github/workflows/release-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Release: Validate PR'

on:
pull_request:
branches: [ master ]
types: [ opened, edited, reopened, synchronize ]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
release-validate:
runs-on: ubuntu-latest
steps:

- name: Validate PR title
run: |
PR_TITLE=$(jq -r ".pull_request.title" $GITHUB_EVENT_PATH)
# check title format and extract tag
if [[ "${PR_TITLE}" =~ ^Release:\ v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
RELEASE_TAG="${PR_TITLE:9}"
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV
else
echo 'PR title must match format "Release: vX.Y.Z(-rc.#)?"'
exit 1
fi
# check that tag doesn't exist
if git ls-remote --exit-code "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}" "refs/tags/${RELEASE_TAG}"; then
echo "The PR title's version exists already"
exit 1
fi
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# slate-connector-looker
Synchronize users from Slate to Looker

## What gets pushed

### Permissions & Roles

We are currently adding the following groups/roles/custom attributes in Looker:

- Role: `Admin` -- Network hub users that have been manually promoted to Administrator or Developer in the hub. This is currently being done directly in the DB.
- Role: `Staff(explore)` -- Slate network site users that are Administrator or Developer's in their respective slate site.
- Role: `Staff(view)` -- Slate network site users that have Staff account level in their respective slate site. This likely needs to be expanded to include Teacher account level slate accounts.
- Group: `[School] Administrators` -- Slate network site users that are Admin/Dev in their respective slate sites.
- Group: `[School] Staff` -- Slate network site users that are Staff/Teacher in their respective slate sites.
- Group: `[School] Students` -- Slate network site users that are Students in their respective slate sites.

### Custom Attributes

- `school`: Set from Slate Network School record config. This is currently only editable directly from the DB. It is also currently only set during the sync workflow when the user has only one school association. This seems fine, however we will likely need to create another workflow for updating this value via a multi-school hub user workflow.
- `student_id`: Set from the slate network users StudentNumber in their respective slate instance.
16 changes: 14 additions & 2 deletions html-templates/connectors/looker/createJob.tpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{extends designs/site.tpl}

{block title}Push to Canvas &mdash; {$dwoo.parent}{/block}
{block title}Push to Looker &mdash; {$dwoo.parent}{/block}

{block content}
<h1>Push to Canvas</h1>
<h1>Push to Looker</h1>

<h2>Input</h2>
<h3>Run from template</h3>
Expand Down Expand Up @@ -56,6 +56,18 @@
</p>
</fieldset>

<fieldset>
<legend>Network Schools</legend>
{foreach from=\Slate\NetworkHub\School::getAll() item=School}
<p>
<label>
{$School->Handle} ({$School->Domain})
<input type="checkbox" name="schools[]" value="{$School->ID}" {refill field=schools checked="true" default="false"}>
</label>
</p>
{/foreach}
</fieldset>

<fieldset>
<legend>User Accounts</legend>
<p>
Expand Down
Loading

0 comments on commit 8001e97

Please sign in to comment.