-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (63 loc) · 2.72 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
56
57
58
59
60
61
62
63
64
65
66
67
name: "Deploy new release"
on:
pull_request:
types:
- closed
branches:
- main
workflow_dispatch:
jobs:
infra:
runs-on: ubuntu-latest
outputs:
env-name: ${{ steps.env-name.outputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
id: creds
uses: aws-actions/configure-aws-credentials@v1
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: Deploy to AWS CloudFormation
id: cf-infra
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: ResearchITWebsiteStack
template: cloudformation.yaml
no-fail-on-empty-changeset: "1"
capabilities: CAPABILITY_IAM,CAPABILITY_NAMED_IAM
role-arn: arn:aws:iam::${{ secrets.AWS_USER_ID }}:role/GithubActionsDeploymentRole
tags: '[{"Key": "group", "Value": "RESEARCHIT"}, {"Key": "project", "Value": "website"}, {"Key": "status", "Value": "prod"}, {"Key": "pushed_by", "Value": "githubaction"}, {"Key": "defined_in", "Value": "cloudformation"}, {"Key": "repo_name", "Value": "uoy-research/research-it-website-infrastructure"}, {"Key": "user", "Value": "sl561"}, {"Key": "team", "Value": "rhpc"}]'
content:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11.3'
- name: Install sphinx
run: pip install -r requirements.txt
- 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: TZ=UTC sphinx-build -a -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 "/*"