update ssh command to add username #221
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v4 | |
- 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@v5 | |
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 "/*" |