Skip to content

Conversation

@richardtbell
Copy link
Contributor

No description provided.

name: Deploy Staging Lambdas
runs-on: ubuntu-latest
container:
image: timbru31/node-alpine-git
Copy link
Contributor

@mateja176 mateja176 Jun 27, 2022

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)?

Copy link
Contributor Author

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?

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

@mateja176 mateja176 Jun 27, 2022

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.

Copy link
Contributor

@mateja176 mateja176 Jun 27, 2022

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

# semantic_version: 19
# - name: Get previous tag
# id: previoustag
# uses: 'WyriHaximus/github-action-get-previous-tag@v1'
Copy link
Contributor

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).

Copy link
Contributor Author

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

@richardtbell richardtbell force-pushed the EHP-232-migrate-lambda-workflows-to-workflows-repo branch 2 times, most recently from b49b77c to 62240f6 Compare June 30, 2022 10:39
@mateja176 mateja176 force-pushed the main branch 6 times, most recently from 9c8b186 to 129b86f Compare July 8, 2022 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants