-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (54 loc) · 2.27 KB
/
deploy.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
name: "Deploy new release"
on:
pull_request:
types:
- closed
branches:
- main
workflow_dispatch:
jobs:
infra:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy CloudFormation Stack
uses: university-of-york/[email protected]
env:
TEMPLATE: cloudformation.yaml
AWS_STACK_NAME: ResearchITWebsiteStack
AWS_REGION: eu-west-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CAPABILITIES: CAPABILITY_IAM CAPABILITY_NAMED_IAM
ROLE_ARN: arn:aws:iam::${{ secrets.AWS_USER_ID }}:role/GithubActionsDeploymentRole
TAGS: group=RESEARCHIT project=website status=prod pushed_by=githubaction defined_in=cloudformation repo_name=uoy-research/research-it-website-infrastructure user=sl561 team=rhpc
content:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11.3'
- name: Install sphinx
run: pip install sphinx sphinx-rtd-theme
- name: Set AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Build site
run: sphinx-build -b html docs/source/ site/
- name: Get Bucket name
id: get-bucket
run: |
echo "{BUCKET_NAME}=$(aws cloudformation describe-stacks --stack-name ResearchITWebsiteStack --query 'Stacks[0].Outputs[?OutputKey==`BucketName`].OutputValue' --output=text)" >> "$GITHUB_OUTPUT"
- name: Get CloudFront distribution id
id: get-distribution-id
run: |
echo "{DISTRIBUTION_ID}=$(aws cloudformation describe-stacks --stack-name ResearchITWebsiteStack --query 'Stacks[0].Outputs[?OutputKey==`CloudFrontDistributionID`].OutputValue' --output=text)" >> "$GITHUB_OUTPUT"
- name: Push to S3
run: aws s3 sync site/. s3://${{steps.get-bucket.outputs.BUCKET_NAME}}
- name: Invalidate CloudFront distribution
run: |
aws cloudfront create-invalidation --distribution-id ${{steps.get-distribution-id.outputs.DISTRIBUTION_ID}} --paths "/*"