This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
88 lines (87 loc) · 3.26 KB
/
main.yaml
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
name: Main
on: [ pull_request ]
jobs:
build-image:
permissions:
contents: read
id-token: write
runs-on:
- ubuntu-latest
env:
BRANCH: ${{ github.head_ref }}
AWS_DEFAULT_REGION: "us-west-2"
ALGOLIA_PRIVATE_KEY: ${{ secrets.AGOLIA_PRIVATE_KEY }}
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to docker
uses: docker/login-action@v2
with:
username: ${{ secrets.NEXUS_USERNAME }}
password: ${{ secrets.NEXUS_PASSWORD }}
- name: Set vars
run: |
if [ "$BRANCH" = "main" ]; then
BUCKET=docs-d2iq-com-preview
HOSTNAME=dev-docs.d2iq.com
else
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
BUCKET="docs-d2iq-com-pr-${PR_NUMBER}"
HOSTNAME="docs-d2iq-com-pr-${PR_NUMBER}.s3-website-us-west-2.amazonaws.com"
fi
echo "::set-env name=BUCKET::$BUCKET"
echo "::set-env name=HOSTNAME::$HOSTNAME"
- name: Pull image
run: docker pull mesosphere/docs:latest
- name: Build image
run: |
cp docker/Dockerfile.production.dockerignore .dockerignore
docker build --cache-from mesosphere/docs:latest -f docker/Dockerfile.production -t mesosphere/docs:latest .
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: ${{ secrets.AWS_DOCS_SITE_ROLE }}
aws-region: us-west-2
- name: Build & Deploy Preview Docs
run: |
docker run \
-v "$PWD/pages":/src/pages \
-e ALGOLIA_PRIVATE_KEY=$ALGOLIA_PRIVATE_KEY \
-e ALGOLIA_UPDATE="" \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
-e BUCKET=${{ env.BUCKET }} \
-e PRINCIPAL=${{ secrets.AWS_DOCS_SITE_ROLE }} \
-e REDIR_HOSTNAME=${{ env.HOSTNAME }} \
-e DOCS_ENV="preview" \
mesosphere/docs /src/ci/deploy.sh
echo "http://${{ env.HOSTNAME }}"
shell: bash
- name: Build & Deploy Main Docs
run: |
docker run \
-v "$PWD/pages":/src/pages \
-e ALGOLIA_PRIVATE_KEY=$ALGOLIA_PRIVATE_KEY \
-e ALGOLIA_UPDATE="true" \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
-e BUCKET=docs-d2iq-com-production \
-e PRINCIPAL="arn:aws:iam::977260619897:role/dcos-docs-site" \
-e REDIR_HOSTNAME="archive-docs.d2iq.com" \
-e DOCS_ENV="production" \
mesosphere/docs /src/ci/deploy.sh
echo "http://archive-docs.d2iq.com"
shell: bash
- name: Push Image and Restart Server
run: |
if [ "$BRANCH" = "main" ]; then
docker push mesosphere/docs:latest
kubectl -n docs-site rollout restart deployment docs-site-dev
kubectl -n docs-site rollout status deploy/docs-site-dev -w --timeout=10m
fi
shell: bash