-
Notifications
You must be signed in to change notification settings - Fork 178
Description
This took a while to figure out so I'd like to share and advise that it'd be nice to see in the README or elsewhere in the documentation.
My use case was that I needed to capture some of my resources.Outputs from a serverless deployment for use with later scripting. For example, here's an excerpt from my serverless.yml file:
resources:
Resources:
host:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0f2b4fc905b0bd1f1
InstanceType: t2.medium
Outputs:
PublicDnsName:
Description: "host public URL"
Value: !GetAtt host.PublicDnsName
With that in place I can run sls info --verbose and capture in that output is the desired PublicDnsName but I have to grep and adjust for that, e.g.
sls info --verbose | grep PublicDnsName | cut -c 16-
All that said, I found it difficult to perform that scrub-and-grab sequence in a Github Action using this container, but finally landed on overwriting the entrypoint and prefixing my command with a -c, which is appended as an argument to the bash invocation. It's a bit confusing to me still, but it's functional:
name: Deploy to Amazon EC2
on:
push:
branches:
- master
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run serverless deployment
uses: serverless/github-action@v1.53.0
with:
args: deploy --stage=dev --verbose
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
SLS_DEBUG: 1
- name: Export sls/aws-ec2 host
uses: serverless/github-action@v1.53.0
with:
args: -c "serverless info --stage=dev --verbose | grep PublicDnsName | cut -c 16- > host.txt"
entrypoint: /bin/bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
SLS_DEBUG: 1
- name: Show site URL for review and testing
run: |
export host=$(cat host.txt)
echo http://$host/