Merge pull request #5 from paulternate/dependabot/pip/tlspc/functions… #161
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: tlspc-sam-package-functions | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'tlspc/functions/**' | |
workflow_dispatch: | |
jobs: | |
upload: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Set up AWS CLI | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Call sam build/package for each function | |
run: | | |
curl -Lo /tmp/aws-sam-cli.zip https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip | |
sudo unzip -q /tmp/aws-sam-cli.zip -d /usr/local/bin/ | |
s3_bucket=venafi-ecosystem | |
s3_prefix=tlspc/functions | |
pushd . > /dev/null | |
cd tlspc/functions/ | |
for dir in *; do | |
if [ -d "${dir}" ]; then | |
echo "processing ${dir}" | |
if [ -f "${dir}/template.yaml" ]; then | |
echo "found ${dir}/template.yaml" | |
pushd . > /dev/null | |
cd "${dir}" | |
sam build | |
sam package --s3-bucket ${s3_bucket} --s3-prefix ${s3_prefix} --force-upload --output-template-file .aws-sam/output.yaml | |
code_uri=$(grep CodeUri < .aws-sam/output.yaml | cut -d ':' -f2- | tr -d ' ') | |
echo "code_uri=${code_uri}" | |
aws s3 mv ${code_uri} s3://${s3_bucket}/${s3_prefix}/${dir}.zip | |
popd > /dev/null | |
fi | |
fi | |
done | |
popd > /dev/null |