-
Notifications
You must be signed in to change notification settings - Fork 2
164 lines (139 loc) · 5.41 KB
/
rebrand-mercury-rising.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Rebrand Mercury-Rising
on:
workflow_call:
push:
branches:
- mercury-rising
jobs:
lint-test-build:
uses: ./.github/workflows/lint-test-build.yml
publish:
needs: [lint-test-build]
runs-on: ubuntu-latest
steps:
# # Setup Auth token to push to github packages
- name: Set NPM Config
run: npm config set '//npm.pkg.github.com/:_authToken=${{ secrets.ACCESS_TOKEN }}'
- name: Add safe directory
run: git config --global --add safe.directory /__w/sage-lib/sage-lib
- name: Clone Sage-Lib Repo
uses: actions/checkout@v4
with:
# pulls all commits (needed for lerna / semantic release to correctly version)
fetch-depth: "0"
# Setup Git Credentials to come from the Bot
- name: Set Bot Email
run: git config user.email "[email protected]"
- name: Set Bot Name
run: git config user.name "Kajabi Automation Bot"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: v0.9.1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7.7'
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://npm.pkg.github.com
- name: Yarn Install
run: yarn install --frozen-lockfile
- name: Lerna Boostrap
run: yarn lerna bootstrap --ci
- name: Build all
run: NODE_OPTIONS=--openssl-legacy-provider yarn build
- name: Lerna Version Develop
run: NODE_OPTIONS=--openssl-legacy-provider yarn lerna publish --canary --yes --preid mercury --registry github --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: Determine git sha to checkout
uses: haya14busa/action-cond@v1
id: gitsha
with:
cond: ${{ github.event_name == 'pull_request' }}
if_true: ${{ github.event.pull_request.head.sha }}
if_false: ${{ github.sha }}
# Envs based on the current branch
- name: Branch Env
id: branch_env
shell: bash
run: |
echo "Running on branch "
if [[ "${{ github.ref }}" == *"refs/tags"* ]]; then
echo "postfix=production" >> $GITHUB_ENV
else
echo "postfix=staging" >> $GITHUB_ENV
fi
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SAGE_ECR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SAGE_ECR_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 1200
role-session-name: SageECRPushSession
- name: Set branch name if not PR
if: github.event_name != 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- name: Set branch name if PR
if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV
- name: Set valid docker tag branch name
run: echo "DOCKER_BRANCH_NAME=$(echo $BRANCH_NAME | sed "s/[^[:alnum:]\-\.\_]/-/g")-$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: true
# Docs Site
- name: Build and push docs site
uses: docker/build-push-action@v2
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_SAGE_DOCS }}
IMAGE_SHA_TAG: ${{ steps.gitsha.outputs.value }}
POSTFIX: ${{ env.postfix }}
with:
file: ./docs/Dockerfile
build-args: |
GITHUB_TOKEN=${{ secrets.ACCESS_TOKEN }}
context: ./docs
push: true
tags: |
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_SHA_TAG }}-release-${{ env.POSTFIX }}
# Storybook Site
- name: Build and push storybook
uses: docker/build-push-action@v2
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_SAGE_STORYBOOK }}
IMAGE_SHA_TAG: ${{ steps.gitsha.outputs.value }}
POSTFIX: ${{ env.postfix }}
with:
file: ./packages/sage-react/Dockerfile
build-args: |
GITHUB_TOKEN=${{ secrets.ACCESS_TOKEN }}
context: ./packages/sage-react/
push: true
tags: |
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_SHA_TAG }}-release-${{ env.POSTFIX }}
# Sassdocs Site
- name: Build and push sassdocs
uses: docker/build-push-action@v2
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_SAGE_SASSDOCS }}
IMAGE_SHA_TAG: ${{ steps.gitsha.outputs.value }}
POSTFIX: ${{ env.postfix }}
with:
file: ./packages/sage-assets/Dockerfile
build-args: |
GITHUB_TOKEN=${{ secrets.ACCESS_TOKEN }}
context: ./packages/sage-assets/
push: true
tags: |
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_SHA_TAG }}-release-${{ env.POSTFIX }}