Skip to content
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 deployment-action #9

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 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,44 +15,50 @@ 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: 🚀deploy preview
run: |
- name: 'deploy: create'
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: preview
ref: ${{ github.head_ref }}

- name: 'deploy: 🚀 start'
run: |
aws s3 sync ./packages/docs/dist/ s3://ods.dev/$SHA7 --delete

- 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: 'deploy: update status'
uses: bobheadxi/[email protected]
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 Slack
- name: 'notify: slack'
run: sh ./scripts/notify-slack.sh
env:
INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
AUTHOR_NAME: ${{github.actor}}
BRANCH_NAME: ${{github.head_ref}}
PULL_REQUEST_ID: ${{github.event.pull_request.number}}

21 changes: 0 additions & 21 deletions .github/workflows/test.yml

This file was deleted.

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