generated from Sage-Bionetworks-IT/lambda-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IT-3013] Migrate to GH Actions (#15)
Migrate to the github actions from the lambda template.
- Loading branch information
1 parent
08dc36f
commit 8a80d5a
Showing
7 changed files
with
116 additions
and
47 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: sam-build | ||
|
||
runs: | ||
# This creates a composite action to be used as a step in a job | ||
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action | ||
using: "composite" | ||
steps: | ||
# Convert Pipfile.lock to requirements.txt for sam | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- run: pip install -U pipenv | ||
shell: bash | ||
|
||
# This needs to be in the 'CodeUri' directory | ||
- run: pipenv requirements > requirements.txt | ||
shell: bash | ||
|
||
# Install aws-sam-cli | ||
- uses: aws-actions/setup-sam@v2 | ||
with: | ||
use-installer: true | ||
|
||
# Use a lambda-like docker container to build the lambda artifact | ||
- run: sam build --use-container | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: post-merge | ||
|
||
on: | ||
# Run on merges to master or tag pushes | ||
push: | ||
branches: [ 'master' ] | ||
tags: [ '*' ] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
|
||
jobs: | ||
lambda-test: | ||
uses: "./.github/workflows/test.yaml" | ||
|
||
package-and-publish: | ||
runs-on: ubuntu-latest | ||
needs: lambda-test | ||
permissions: | ||
id-token: write | ||
env: | ||
BOOTSTRAP_BUCKET: bootstrap-awss3cloudformationbucket-19qromfd235z9 | ||
ESSENTIALS_BUCKET: essentials-awss3lambdaartifactsbucket-x29ftznj6pqw | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# Install sam-cli and run "sam build" | ||
- uses: ./.github/actions/sam-build | ||
|
||
# authenticate with AWS via OIDC | ||
- uses: aws-actions/configure-aws-credentials@v3 | ||
with: | ||
aws-region: us-east-1 | ||
role-to-assume: arn:aws:iam::745159704268:role/sagebase-github-oidc-lambda-template-deploy-sageit | ||
role-session-name: GHA-${{ github.event.repository.name }}-${{ github.run_id }} # Must not exceed 64 chars | ||
role-duration-seconds: 900 | ||
|
||
# upload the lambda artifact to s3 and generate a cloudformation template referencing it | ||
- run: sam package --template-file .aws-sam/build/template.yaml --s3-bucket $ESSENTIALS_BUCKET --s3-prefix ${{ github.event.repository.name }}/${{ github.ref_name }} --output-template-file .aws-sam/build/${{ github.event.repository.name }}.yaml | ||
|
||
# upload the generated cloudformation template to s3 | ||
- run: aws s3 cp .aws-sam/build/${{ github.event.repository.name }}.yaml s3://$BOOTSTRAP_BUCKET/${{ github.event.repository.name }}/${{ github.ref_name }}/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: pre-merge | ||
|
||
on: | ||
# Run on open pull requests | ||
pull_request: | ||
|
||
jobs: | ||
lambda-test: | ||
uses: "./.github/workflows/test.yaml" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: lambda-test | ||
|
||
on: | ||
# This is a dispatched workflow to be called as a job in other workflows | ||
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow | ||
workflow_call: | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- uses: pre-commit/[email protected] | ||
|
||
pytest: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- run: pip install -U pipenv | ||
- run: pipenv install --dev | ||
- run: pipenv run python3 -m pytest tests/ -vv | ||
|
||
sam-build-and-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/sam-build | ||
- run: sam validate --lint --template .aws-sam/build/template.yaml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,3 +133,6 @@ dmypy.json | |
|
||
# SAM | ||
.aws-sam/ | ||
|
||
# generated dynamically from Pipfile | ||
requirements.txt |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.