Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Folders missing from git archive

Nick Collins June 8, 2020

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.

1 answer

1 accepted

0 votes
Answer accepted
ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 8, 2020

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
Nick Collins June 9, 2020

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!

ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2020

relative from the base directory, which files / directories do you need in application.tar in the end?

Nick Collins June 10, 2020

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
Like ktomk likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events