-
Notifications
You must be signed in to change notification settings - Fork 0
Add deploy-lambdas reusable workflow #5
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
base: main
Are you sure you want to change the base?
Add deploy-lambdas reusable workflow #5
Conversation
| name: Deploy Staging Lambdas | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: timbru31/node-alpine-git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that you chose timbru31/node-alpine-git because it based on the official node alpine image with the benefit of having git installed. Do you think that the comfort eliminating the apk install git is worth it compared to using the official node image which offers more version and is more up to date (as a consequence more secure under some circumstances)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really I just copied it from the other workflow. @thejamespower made the change I believe - what are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably better to use the official one and use apk to add git, I was just being lazy
| cache: npm | ||
| - name: 'NPM: Add Config and Authorization' | ||
| run: | | ||
| rm -f .npmrc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .npmrc file might not exist which would cause rm to exit with a non-zero exit code. Also redirecting the echo command output below, using >, will surely override the contents of .npmrc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK the -f flag means that if it doesn't exist it won't error. Also as I remember I had found that > wasn't overriding the original file... quite likely I made some sort of mistake though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right about the -f flag. Although it can also be used for ignoring confirmation prompts and similar. The redirection should work on the other hand. One possibility is that the original .npmrc file is protected and as such cannot be overriden, thus must be forcefully removed and recreated. Though I don't think that's likely.
| npm ci | ||
| npm run build | ||
| rm -rf node_modules | ||
| npm ci --only=production --ignore-scripts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --only-production option is not referenced in the documentation. Would you go along with removing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah looks like npm prune --production is a better option for what they're trying to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting remark. In summary, since NODE_ENV is not set to production, npm ci will install devDepedencies which are required to build. Afterwards, they can be removed via npm prune --production. Consequently, rm -rf node_modules is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, in case that all depdencies, including devDependencies are installed, running cross-env NODE_ENV=production npm ci will result in the removal of devDependencies. However, semantically spreaking, the prune command makes much more sense.
On the other hand, considering that npm ci will override versions based on the current values specfied in package.json and package-lock.json, the first rm -rf node_modules command is redundant as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm prune didn't work as I expected and we were left with a massive zip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reference npm-prune demo.
.github/workflows/deploy-lambdas.yml
Outdated
| # semantic_version: 19 | ||
| # - name: Get previous tag | ||
| # id: previoustag | ||
| # uses: 'WyriHaximus/github-action-get-previous-tag@v1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the section is commented out, I assume that your intention might be to remove it. Although, if you decide to keep it, pray consider using git describe --tags $(git rev-list --tags --max-count=1) to get the latest tag (reference).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's commented out for now as we were trying to get James' branch deployed and there were various issues interfering
b49b77c to
62240f6
Compare
9c8b186 to
129b86f
Compare
No description provided.