-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (61 loc) · 2.35 KB
/
Copy pathdeploy.yml
File metadata and controls
63 lines (61 loc) · 2.35 KB
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
name: Deploy to Environment
on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
type: choice
options:
- staging
- production
version:
description: 'Package version to deploy'
required: true
type: string
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
contents: read
packages: read
steps:
- name: Checkout infra template
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
repository: LibreTexts/infrastructure
token: ${{ secrets.LIBREBOT_ACCESS_TOKEN }}
path: infra
persist-credentials: false
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.AWS_DEPLOY_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_DEPLOY_SECRET_ACCESS_KEY }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Amazon ECR
id: ecr-login
uses: aws-actions/amazon-ecr-login@d539f0932e70871a027e9d5a9d8fc38589180a64 # v2.1.6
- name: Mirror image from GHCR to ECR
env:
GHCR_IMAGE: ghcr.io/libretexts/molview-lambda-api:${{ inputs.version }}
ECR_IMAGE: ${{ steps.ecr-login.outputs.registry }}/${{ vars.AWS_ECR_REPO }}:${{ inputs.version }}
run: |
docker pull "$GHCR_IMAGE"
docker tag "$GHCR_IMAGE" "$ECR_IMAGE"
docker push "$ECR_IMAGE"
- name: Deploy CloudFormation stack
uses: aws-actions/aws-cloudformation-github-deploy@81e3b03d2266bcb76c4bcc37a7d71d9cb67838bb # v2.2.0
with:
name: ${{ vars.AWS_STACK_NAME }}
template: infra/molview/api.json
role-arn: ${{ secrets.AWS_ROLE_ARN }}
capabilities: 'CAPABILITY_NAMED_IAM'
parameter-overrides: 'MolViewApiEnvironment=${{ inputs.environment }},MolViewApiImage=${{ steps.ecr-login.outputs.registry }}/${{ vars.AWS_ECR_REPO }}:${{ inputs.version }}'