Skip to content

Test new workflow

Test new workflow #28

Workflow file for this run

name: Update Lambda Functions
on:
push:
branches:
- dev
- qa
- staging
- main
# Permission can be added at job level or workflow level
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
# pull-requests: write
# repository-projects: write
# issues: write
jobs:
changes:
runs-on: ubuntu-latest
outputs:
lambdas: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
lambda-1:
- 'lambda-1/**'
lambda-2:
- 'lambda-2/**'
deploy-lambdas:
if: ${{ needs.changes.outputs.lambdas != '[]' }}
needs: changes
env:
EXECUTION: 'true'
strategy:
matrix:
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['batch-adapter', 'dv-s3-transfer'] if both lambda folders contains changes
lambdas: ${{ fromJSON(needs.changes.outputs.lambdas) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Stage
shell: bash
run: |
if [ $GITHUB_REF_NAME == "main" ]
then
echo "export STAGE=prod" >> ~/.bash_profile
elif [ $GITHUB_REF_NAME == "dev" ]
then
echo "export STAGE=dev" >> ~/.bash_profile
elif [ $GITHUB_REF_NAME == "qa" ]
then
echo "export STAGE=enterprise" >> ~/.bash_profile
elif [ $GITHUB_REF_NAME == "staging" ]
then
echo "export STAGE=staging" >> ~/.bash_profile
else
echo "export STAGE=dirty" >> ~/.bash_profile
echo "EXECUTION=false" >> $GITHUB_ENV
fi
# Login
- name: Login to AWS
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: AWS_FederatedOIDC_for_lambda
aws-region: ${{ secrets.AWS_REGION }}
# Deploy Services
- name: Update Lambda ${{ matrix.lambdas }}
if: ${{ env.EXECUTION == 'true' }}
shell: bash
run: |
source ~/.bash_profile
cd ${{ matrix.lambdas }}
zip -r function.zip *
aws lambda update-function-code --function-name "${{ matrix.lambdas }}-$STAGE" --zip-file fileb://function.zip