I had originally deployed this portfolio website using gitlab and netlify. However I was having issues with netlify receiving and correctly using my environment variables so I am attempting to cut out the middleman and just deploy fully using gitlab pages. I do not have very much experience with deployment so I’ve been implementing some fixes here and there that I have found from other questions posted here as well as stack overflow but I always end up around the same spot… pages:deploy missing pages artifacts. As I am rather inexperienced with deployment I’m not entirely sure where to look for my issue or entirely what is going wrong.
My current yml file and logs look like this:
image: node:16
before_script:
- cd portfolio
- |
if [ “$SET_PERMISSIONS” = “true” ]; then
if [ -d “node_modules” ]; then
chmod +x node_modules/.bin/react-scripts
fi
fi - CI=false npm install
- cp build/index.html build/404.html
- echo “REACT_APP_SERVICE_ID=$REACT_APP_SERVICE_ID” >> .env
- echo “REACT_APP_YOUR_API_KEY=$REACT_APP_YOUR_API_KEY” >> .env
- echo “REACT_APP_YOUR_TEMPLATE_ID=$REACT_APP_YOUR_TEMPLATE_ID” >> .env
- CI=false npm run build
- ls -R $CI_PROJECT_DIR/portfolio/public
build:
stage: build
script:
- ls
artifacts:
paths:
- $CI_PROJECT_DIR/portfolio/public
only:
- main
pages:
stage: deploy
script:
- echo “Deploying to GitLab Pages…”
dependencies:
- build
only:
- main
Build log:
Running with gitlab-runner 16.3.0~beta.108.g2b6048b4 (2b6048b4)
on green-3.saas-linux-small-amd64.runners-manager.gitlab.com/default Jhc_Jxvh, system ID: s_0e6850b2bce1
`
feature flags: FF_USE_IMPROVED_URL_MASKING:true, FF_RESOLVE_FULL_TLS_CHAIN:false Preparing the “docker+machine” executor
Using Docker executor with image node:16 …
Pulling docker image node:16 …
Using docker image sha256:1ddc7e4055fdb6f6bf31063b593befda814294f9f904b6ddfc21ab1513bafa8e for node:16 with digest node@sha256:f77a1aef2da8d83e45ec990f45df50f1a286c5fe8bbfb8c6e4246c6389705c0b …
Preparing environment
Running on runner-jhcjxvh-project-48171294-concurrent-0 via runner-jhcjxvh-s-l-s-amd64-1695068411-b9e3969a…
Getting source from Git repository
Fetching changes with git depth set to 20…
Initialized empty Git repository in /builds/baumajam/portfolio/.git/
Created fresh repository.
Checking out 8c270849 as detached HEAD (ref is main)…
Skipping Git submodules setup
$ git remote set-url origin “${CI_REPOSITORY_URL}”
Executing “step_script” stage of the job script
Using docker image sha256:1ddc7e4055fdb6f6bf31063b593befda814294f9f904b6ddfc21ab1513bafa8e for node:16 with digest node@sha256:f77a1aef2da8d83e45ec990f45df50f1a286c5fe8bbfb8c6e4246c6389705c0b …
$ cd portfolio
$ if [ “$SET_PERMISSIONS” = “true” ]; then # collapsed multi-line command
$ CI=false npm install
up to date, audited 1518 packages in 3s
241 packages are looking for funding
run npm fund
for details
7 vulnerabilities (1 moderate, 6 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run npm audit
for details.
$ cp build/index.html build/404.html
$ echo “REACT_APP_SERVICE_ID=$REACT_APP_SERVICE_ID” >> .env
$ echo “REACT_APP_YOUR_API_KEY=$REACT_APP_YOUR_API_KEY” >> .env
$ echo “REACT_APP_YOUR_TEMPLATE_ID=$REACT_APP_YOUR_TEMPLATE_ID” >> .env
$ CI=false npm run build
> portfolio@0.1.0 build
> react-scripts build
Creating an optimized production build…
Compiled successfully.
File sizes after gzip:
60.73 kB (-25 B) build/static/js/main.01a8764a.js
1.16 kB (-36 B) build/static/css/main.66d44d27.css
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
You may serve it with a static server:
npm install -g serve
serve -s build
Find out more about deployment here:
Deployment | Create React App
$ ls -R $CI_PROJECT_DIR/portfolio/public
/builds/baumajam/portfolio/portfolio/public:
Images
favicon.ico
index.html
logo192.png
logo512.png
manifest.json
robots.txt
/builds/baumajam/portfolio/portfolio/public/Images:
itsame.jpg
$ ls
README.md
build
node_modules
package-lock.json
package.json
public
src
Uploading artifacts for successful job
Uploading artifacts…
/builds/baumajam/portfolio/portfolio/public: found 9 matching artifact files and directories
WARNING: Upload request redirected location=https://gitlab.com/api/v4/jobs/5114293933/artifacts?artifact_format=zip&artifact_type=archive new-url=https://gitlab.com
WARNING: Retrying… context=artifacts-uploader error=request redirected
Uploading artifacts as “archive” to coordinator… 201 Created id=5114293933 responseStatus=201 Created token=64__xk57
Cleaning up project directory and file based variables
Job succeeded`
deploy logs:
Running with gitlab-runner 16.3.0~beta.108.g2b6048b4 (2b6048b4)
on green-1.saas-linux-small-amd64.runners-manager.gitlab.com/default JLgUopmM, system ID: s_deaa2ca09de7
feature flags: FF_USE_IMPROVED_URL_MASKING:true, FF_RESOLVE_FULL_TLS_CHAIN:false
`Preparing the “docker+machine” executor
Using Docker executor with image node:16 …
Pulling docker image node:16 …
Using docker image sha256:1ddc7e4055fdb6f6bf31063b593befda814294f9f904b6ddfc21ab1513bafa8e for node:16 with digest node@sha256:f77a1aef2da8d83e45ec990f45df50f1a286c5fe8bbfb8c6e4246c6389705c0b …
Preparing environment
Running on runner-jlguopmm-project-48171294-concurrent-0 via runner-jlguopmm-s-l-s-amd64-1695068472-65f89e40…
Getting source from Git repository
Fetching changes with git depth set to 20…
Initialized empty Git repository in /builds/baumajam/portfolio/.git/
Created fresh repository.
Checking out 8c270849 as detached HEAD (ref is main)…
Skipping Git submodules setup
$ git remote set-url origin “${CI_REPOSITORY_URL}”
Downloading artifacts
Downloading artifacts for build (5114293933)…
Downloading artifacts from coordinator… ok host=storage.googleapis.com id=5114293933 responseStatus=200 OK token=64_ePaSb
Executing “step_script” stage of the job script
Using docker image sha256:1ddc7e4055fdb6f6bf31063b593befda814294f9f904b6ddfc21ab1513bafa8e for node:16 with digest node@sha256:f77a1aef2da8d83e45ec990f45df50f1a286c5fe8bbfb8c6e4246c6389705c0b …
$ cd portfolio
$ if [ “$SET_PERMISSIONS” = “true” ]; then # collapsed multi-line command
$ CI=false npm install
up to date, audited 1518 packages in 3s
241 packages are looking for funding
run npm fund
for details
7 vulnerabilities (1 moderate, 6 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run npm audit
for details.
$ cp build/index.html build/404.html
$ echo “REACT_APP_SERVICE_ID=$REACT_APP_SERVICE_ID” >> .env
$ echo “REACT_APP_YOUR_API_KEY=$REACT_APP_YOUR_API_KEY” >> .env
$ echo “REACT_APP_YOUR_TEMPLATE_ID=$REACT_APP_YOUR_TEMPLATE_ID” >> .env
$ CI=false npm run build
> portfolio@0.1.0 build
> react-scripts build
Creating an optimized production build…
Compiled successfully.
File sizes after gzip:
60.73 kB (-25 B) build/static/js/main.01a8764a.js
1.16 kB (-36 B) build/static/css/main.66d44d27.css
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
You may serve it with a static server:
npm install -g serve
serve -s build
Find out more about deployment here:
Deployment | Create React App
$ ls -R $CI_PROJECT_DIR/portfolio/public
/builds/baumajam/portfolio/portfolio/public:
Images
favicon.ico
index.html
logo192.png
logo512.png
manifest.json
robots.txt
/builds/baumajam/portfolio/portfolio/public/Images:
itsame.jpg
$ echo “Deploying to GitLab Pages…”
Deploying to GitLab Pages…
Cleaning up project directory and file based variables
Job succeeded