webfactory / create-aws-codedeploy-deployment

Action to create AWS CodeDeploy deployments from GitHub Actions workflows
MIT License
21 stars 8 forks source link

TypeError: Cannot read property 'match' of undefined at Object.exports.createDeployment #5

Closed npmoyer closed 3 years ago

npmoyer commented 3 years ago

I am encountering this error when running the workflow action. I'm able to manually create a deployment in AWS but not from the action as I get the following error when running the workflow. I'm not sure what I'm missing here so any help would be appreciated.

Run webfactory/create-aws-codedeploy-deployment@v0.2.1
🎋 On branch 'aws', head commit c05d4429909487acca2b81f48117d78a2a14392a
💡 Using appspec.yml -> branch_config 'aws' for branch 'aws'
🎳 Using deployment group 'demo'
⚙️  Updated deployment group 'demo'
(node:2404) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'match' of undefined
    at Object.exports.createDeployment (/home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.1/dist/index.js:104:66)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:2404) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2404) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

My appspec.yml:

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu/app
hooks:
  AfterInstall:
    - location: ./install-app.sh
      timeout: 300
      runas: root

# This section controls the action:
branch_config:
  aws:
      deploymentGroupName: demo
      deploymentGroupConfig:
          serviceRoleArn: arn:aws:iam::555036407157:role/code-deploy-role
          ec2TagFilters:
                - { Type: KEY_AND_VALUE, Key: name, Value: AppServer }
      deploymentConfig:
          autoRollbackConfiguration:
              enabled: true

My release-aws.yml:

# This is a basic workflow to help you get started with Actions

name: Release-AWS

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ aws ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    -   uses: aws-actions/configure-aws-credentials@v1
        with:
            aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
            aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
            aws-region: us-east-1
    -   uses: actions/checkout@v2
    -   id: deploy
        uses: webfactory/create-aws-codedeploy-deployment@v0.2.1
    -   uses: peter-evans/commit-comment@v1
        with:
            token: ${{ secrets.GITHUB_TOKEN }}
            body: |
                @${{ github.actor }} this was deployed as [${{ steps.deploy.outputs.deploymentId }}](https://console.aws.amazon.com/codesuite/codedeploy/deployments/${{ steps.deploy.outputs.deploymentId }}?region=us-east-1) to group `${{ steps.deploy.outputs.deploymentGroupName }}`.
m-atia commented 3 years ago

I am also getting this issue. @NPMoyer Were you able to resolve this?

hancush commented 3 years ago

I'm experiencing this, as well. Link to the build, if it's helpful: https://github.com/datamade/la-metro-councilmatic/runs/1501527170

mpdude commented 3 years ago

Has there been a successful deployment before, or was this the very first deployment attempt?

If there was a previous deployment, could you obtain the deployment description (probably the API method is called GetDeployment?) with the AWS CLI?

hancush commented 3 years ago

Hi, @mpdude – Yes, we've had successful deployments with your action, which is great, by the way – thank you! The description of the last successful deployment with the action prior to the error is Created by webfactory/create-aws-codedeploy-deployment (run_number=11). Here is the corresponding build: https://github.com/datamade/la-metro-councilmatic/runs/1500953012.

Interestingly, deployments via action are working again as of this morning.

I'm not sure what would be useful for debugging, but my workflow when I encountered the error was:

Let me know if there's any more information I can provide to help out!

hancush commented 3 years ago

Bummer, this seems to be happening pretty consistently now. Latest failure to deploy: https://github.com/datamade/la-metro-councilmatic/runs/1538459890

hancush commented 3 years ago

Ah, ~@NPMoyer~ @mpdude, I bet this is the issue you resolved in https://github.com/webfactory/create-aws-codedeploy-deployment/commit/0d7a684950dae16883a140dd950257958730e0b5! Looks like that commit is not in your latest release: https://github.com/webfactory/create-aws-codedeploy-deployment/releases/tag/v0.2.1. Do you have plans to cut a new release with the fix, perchance?

(Sorry for the mix up in tagging. TGIF, eh? 🙃)

mpdude commented 3 years ago

Hope I will be able to do so on Monday. Until then, you could try to reference the commit ID instead of the Tag reference when using the action.

Does it work consistently then?

hancush commented 3 years ago

@mpdude Thanks for the tip! Didn't realize you could pin an action to a commit – done in https://github.com/datamade/la-metro-councilmatic/pull/684. So far, so good on deployments. Will update this thread if this error recurs (or open a separate issue if we see a new one).

mpdude commented 3 years ago

@hancush In fact, when you're ~a bit paranoid~  more security conscious, it would be a good practice to always review the code shipped by an action and then pin it by commit. Otherwise, action authors might... well... change things/move tags (if only for a short time) and you might run things on your workflows that you are not aware of. Just sayin'...

mpdude commented 3 years ago

@NPMoyer I've tagged v0.2.2, hoping that it will resolve your issue.

If it does, could you please close this issue here?

Thank you all for your patience and helping to resolve this!

npmoyer commented 3 years ago

Hey @mpdude it seems it was tagged as "0.2.2" and not "v0.2.2" since I am getting this error:

Failed to resolve action download info. Error: Unable to resolve action webfactory/create-aws-codedeploy-deployment@v0.2.2, unable to find version v0.2.2

It did fix the issue though!

mpdude commented 3 years ago

@NPMoyer fixed the release tag (added the correct v0.2.2, but kept the wrong 0.2.2 to avoid breakages).