I have the following pipeline script for my express and react application:
image: node:10.15.3
pipelines:
default:
- step:
name: Installing API server dependencies
script:
- npm install
- step:
name: Install client dependencies & build
script:
- cd client
- npm install
- npm run build
- step:
name: Create artifact
script:
- git archive --format=tar.gz master -o application.tar.gz
artifacts:
- application.tar.gz
- step:
name: Deploy to test
deployment: test
script:
- pipe: atlassian/heroku-deploy:0.1.1
variables:
HEROKU_API_KEY: $HEROKU_API_KEY
HEROKU_APP_NAME: $HEROKU_APP_NAME
ZIP_FILE: application.tar.gz
However, when the ZIP file application.tar.gz is passed to Heroku, the deployment is successful but the build folder is missing from it when I list the contents. It's almost like the step: Install client dependencies & build has had no effect, but it does run and the logs show everything I would expect to create a production build of the react app.
Technically the folder isn't missing as git-archive does only contain files (objects) from the repository - not the working tree.
What you could do is create the archive first, then append the build directory to it and finally compress it:
git archive --format=tar master -o application.tar
tar --append --file=application.tar build
gzip application.tar
Hi @ktomk, that makes sense to me, however when I try the above I just get the following message:
tar: client/build: Cannot stat: No such file or directory
Are there other steps I need to complete for this to work? The location of my react app builder folder is in client/build.
Will I also need to append node_modules? I basically just want to release a finished artifact to Heroku.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
relative from the base directory, which files / directories do you need in application.tar in the end?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @ktomk, I figured it out! Thanks for your initial answer, it helped me a lot. This was the completed steps I ended up with in the end:
- step:
name: Install client app dependencies & build
script:
- cd client
- npm install
- npm run build
artifacts:
- client/build/**
- step:
name: Create artifact
script:
- git archive --format=tar master -o app.tar
- tar --append --file=app.tar client/build
- gzip app.tar
artifacts:
- app.tar.gz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.