Skip to content

Commit

Permalink
update preview script
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoldsandoval-okta committed Nov 17, 2020
1 parent 9ef6860 commit 4b4bfaa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 64 deletions.
49 changes: 17 additions & 32 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
name: Preview
on:
pull_request:
branches:
- master
- develop
- "release/**"
name: preview
on: [push, pull_request]
jobs:
deployment:
runs-on: ubuntu-latest
Expand All @@ -20,57 +15,47 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: set $SHA7
run: echo ::set-env name=SHA7::$(git rev-parse --short ${{ github.event.pull_request.head.sha || github.sha }})

run: echo "SHA7=$(git rev-parse --short ${{ github.event.pull_request.head.sha || github.sha }})" >> $GITHUB_ENV
- name: set $PREVIEW_URL
run: echo ::set-env name=PREVIEW_URL::"https://"$SHA7".ods.dev"
run: echo "PREVIEW_URL="https://${SHA7}.ods.dev"" >> $GITHUB_ENV

- name: get COMMIT_MSG
run: |
MSG=$(git log --format=%B -n 1 ${{ github.event.after }})
echo "::set-env name=COMMIT_MSG::${MSG}"
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
run: echo "COMMIT_MSG=$(git log --format=%B -n 1 ${{ github.event.after }})" >> $GITHUB_ENV

- name: install dependencies
run: yarn

- name: test
run: ./node_modules/lerna/cli.js run test

- name: build docs
run: yarn workspace @okta/design-docs build

- name: start deployment
uses: bobheadxi/deployments@master
- name: 'deploy: create'
uses: bobheadxi/deployments@v0.4.2
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: release
env: preview
ref: ${{ github.head_ref }}

- name: 🚀 deploy
- name: 'deploy: 🚀 start'
run: |
aws s3 sync ./packages/docs/dist/ s3://ods.dev/$SHA7 --delete
- name: update deployment status
uses: bobheadxi/deployments@master
- name: 'deploy: update status'
uses: bobheadxi/deployments@v0.4.2
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ env.PREVIEW_URL }}

# - name: notify GitHub
# run: sh ./scripts/notify-gh.sh
# env:
# INCOMING_WEBHOOK_URL: ${{ github.event.pull_request.comments_url }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: notify Slack
- name: 'notify: slack'
run: sh ./scripts/notify-slack.sh
env:
INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Expand Down
8 changes: 0 additions & 8 deletions scripts/notify-gh.sh

This file was deleted.

32 changes: 8 additions & 24 deletions scripts/notify-slack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,31 @@ curl \
-X POST \
-H "Content-Type: application/json" \
--data '
{
"blocks": [
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": ":white_check_mark: *Preview Deployed*"
"text": ":rocket: *Preview Deployed*"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "> '"$COMMIT_MSG"'"
"text": "> '"$COMMIT_MSG"'"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Pull Request #'"$PULL_REQUEST_ID"'",
"emoji": true
},
"url": "https://github.com/okta/odyssey/pull/'"$PULL_REQUEST_ID"'"
},
{
"type": "button",
"style": "primary",
"text": {
"type": "plain_text",
"text": "Visit Preview",
"emoji": true
},
"url": "'"$PREVIEW_URL"'"
}
]
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<https://github.com/okta/odyssey/pull/'"$PULL_REQUEST_ID"'|Pull Request '"$PULL_REQUEST_ID"'> ∙ *<'"$PREVIEW_URL"'|View Deployment>*"
}
},
{
"type": "context",
Expand Down

0 comments on commit 4b4bfaa

Please sign in to comment.