Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command hook for frontend SSG deployments #3914

Open
3 tasks done
ramkumarHFN opened this issue Mar 12, 2024 · 1 comment
Open
3 tasks done

Command hook for frontend SSG deployments #3914

ramkumarHFN opened this issue Mar 12, 2024 · 1 comment
Labels
feature-request New feature or request

Comments

@ramkumarHFN
Copy link

Before opening, please confirm:

Amplify Hosting feature

Build settings, Frontend builds

Is your feature request related to a problem? Please describe:

I am having a use-case of developing several NextJS applications (SSG) and deploying them to AWS Amplify. I am using AWS amplify hosting, where directly linking each GitHub repository to amplify apps. And configuring YAML file for frontend deployment. All applications are deployed and working fine.

Problem statement: Now I need to setup a quality gate in the deployment process, Where I have to check certain parameters (Package version of few NPM modules) before deployment.

I am trying to implement this with command hooks. Officially its mentioned pre and post push hooks will get triggered by default in amplify hosting.

I have added amplify/hooks folder.

When I tried to trigger a build, these hook scripts are not getting executed. Is it applicable only for backend execution?

Is there any other better way to handle this use-case with AWS amplify CICD for SSG deployments?

Describe how you'd like this feature to work

Currently I am trying with cURL to pass the data to an API.

version: 1
frontend:
phases:
preBuild:
commands:
- NEXT_VERSION=$(node -p -e "require('./package.json').dependencies.next")
- REACT_VERSION=$(node -p -e "require('./package.json').dependencies.react")
- echo $NEXT_VERSION
- echo $REACT_VERSION
- RES=$(curl -s -X POST -H "Content-type: application/json" -d {"next":"1.00","react":"1.1.0"} [endpoint])
- echo $RES
- npm ci
build:
commands:
- rm -rf .next
- npm run build
artifacts:
baseDirectory: .next/
files:
- '/*'
cache:
paths:
- node_modules/
/*

But receiving an error as

[ERROR]: !!! CustomerError: The commands provided in the buildspec are malformed. Please ensure that you have properly escaped reserved YAML characters. If you have a ':' character in your command, encapsulate the command within quotes.

But while executing the same buildspec without assigning the curl response to a variable its executing properly.

Is there any easy way to post required info to external APIs via hooks in frontend deployment.

@ramkumarHFN ramkumarHFN added the feature-request New feature or request label Mar 12, 2024
Copy link

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant