Skip to content
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

adds GitLab CI file #208

Closed
wants to merge 2 commits into from
Closed

adds GitLab CI file #208

wants to merge 2 commits into from

Conversation

SSmale
Copy link
Contributor

@SSmale SSmale commented Dec 31, 2023

For anyone looking to use GitLab for hosting, this is the configuration I used to verify the code and bundle and push it

fully qualifies the `npm run ci` script
@satnaing
Copy link
Owner

satnaing commented Jan 2, 2024

Like I previously said,

Appreciate your suggestion and effort.
However, I'm thinking of adding a how-to blog post for adding GitLab CI file. This is because AstroPaper is aimed to be as minimal as possible; and, besides, not everyone using AstroPaper would need this feature. But if someone does, they can opt in this feature by following the how-to blog post guide.

Just like in the https://astro-paper.pages.dev/tags/faq/
Or maybe move this into a discussion 🤷

@SSmale
Copy link
Contributor Author

SSmale commented Jan 2, 2024

I have a write up here so as a post might work

@satnaing
Copy link
Owner

satnaing commented Jan 5, 2024

Hello @SSmale
Maybe we should move this into the discussions section?

@SSmale
Copy link
Contributor Author

SSmale commented Jan 10, 2024

Sounds good, but how easy is it search in there for the code? I do like the idea of these additional features being captured in the repo as a blog post.

Something like this https://github.com/withastro/docs/tree/main/.github/ISSUE_TEMPLATE might be an idea to have as well as https://github.com/withastro/docs/blob/main/.github/PULL_REQUEST_TEMPLATE.md so that there is some documented guidance on what you want people to capture where

@peterschmidler
Copy link

I tried to deploy with the gitlab-ci file from the pull request but the deploy failed at the first step.

Before I used a simple deploy script like this but it also fails, probably because nom run build works differently than with other astro projects.

Anyone has any clue how I can get my deploy working?

# The Docker image that will be used to build your app
image: node:lts

before_script:
  # Functions that should be executed before the build script is run
  - npm install

pages:
  script:
    # Specify the steps involved to build your app here
    - npm run build
  artifacts:
    paths:
      # The folder that contains the built files to be published. This
      # must be called "public".
      - public

  only:
    # Trigger a new build and deploy only when there is a push to the
    # below branch(es)
    - main

@SSmale
Copy link
Contributor Author

SSmale commented Jun 10, 2024

Hey, do you have a copy of the error message?

Below is a full copy of the file I use to deploy my blog, this line is very important for reasons I can't remember - npm pkg delete scripts.prepare

stages:
  - code-style
  - build
  - deploy
  - release

default:
  image: node:20.10.0
  before_script:
    - npm pkg delete scripts.prepare
    - npm run ci

cache:
    - &global_cache_node_mods
      key:
          files:
              - package-lock.json
      paths:
          - .npm/
      policy: pull 

install_dependencies:
  stage: .pre
  script:
    - npm run ci
  cache:
    - <<: *global_cache_node_mods
      when: on_success
      policy: pull-push
  artifacts:
    paths:
      - .npm
  only:
    changes:
      - package.json

lint-job:
  stage: code-style
  script: 
    - echo "Starting to lint the application..."
    - npm run lint
    - echo "Finished linting the application..."

format-job:
  stage: code-style
  script: 
    - echo "Starting to format check the application..."
    - npm run format:check
    - echo "Finished format checking the application..."

build-job:
  stage: build
  script:
    - echo "Building the code..."
    - npm run build
    - echo "Build complete."
  artifacts:
    name: "astro-paper-blog"
    when: on_success
    expire_in: "30 days"
    paths:
      - "dist/*"

pages:
  stage: deploy  
  environment: production
  dependencies:
    - "build-job"
  variables:
    GIT_STRATEGY: none
  before_script:
    - ''
  script:
    - mv dist public
  artifacts:
    paths:
      - public
  only:
    - main

release_job:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  before_script:
    - ''
  rules:
    - if: $CI_COMMIT_TAG
      when: never                                  # Do not run this job when a tag is created manually
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH  # Run this job when commits are pushed or merged to the default branch
  script:
    - echo "running release_job for $TAG"
  release:                                         # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
    tag_name: 'v0.$CI_PIPELINE_IID'                # The version is incremented per pipeline.
    description: 'v0.$CI_PIPELINE_IID'
    ref: '$CI_COMMIT_SHA'

@peterschmidler
Copy link

Hey,
thanks for following up!
The format- and lint-jobs fail because npm ru ci fails with Missing script: "ci", and all the other steps don't even run.

@SSmale
Copy link
Contributor Author

SSmale commented Jun 11, 2024

Can you try taking out the 'run' part? You can just use install to check everything is setup and then investigate this bit after.

@peterschmidler
Copy link

�[0KRunning with gitlab-runner 17.0.0 (44feccdf)�[0;m
�[0K  on docker-runner xdE67sqh, system ID: s_5cfd43bdb783�[0;m
section_start:1718111547:prepare_executor
�[0K�[0K�[36;1mPreparing the "docker" executor�[0;m�[0;m
�[0KUsing Docker executor with image node:20.10.0 ...�[0;m
�[0KPulling docker image node:20.10.0 ...�[0;m
�[0KUsing docker image sha256:67d9cdb160166226de55337f6b14c44d576cf14f10cd0fb9fbd7854b04dad8ba for node:20.10.0 with digest node@sha256:8d0f16fe841577f9317ab49011c6d819e1fa81f8d4af7ece7ae0ac815e07ac84 ...�[0;m
section_end:1718111548:prepare_executor
�[0Ksection_start:1718111548:prepare_script
�[0K�[0K�[36;1mPreparing environment�[0;m�[0;m
Running on runner-xde67sqh-project-14-concurrent-0 via gitlab...
section_end:1718111549:prepare_script
�[0Ksection_start:1718111549:get_sources
�[0K�[0K�[36;1mGetting source from Git repository�[0;m�[0;m
�[32;1mFetching changes with git depth set to 20...�[0;m
Reinitialized existing Git repository in /builds/maxwel-cloud/maxwel-news/.git/
�[32;1mChecking out 5839a344 as detached HEAD (ref is main)...�[0;m

�[32;1mSkipping Git submodules setup�[0;m
section_end:1718111549:get_sources
�[0Ksection_start:1718111549:restore_cache
�[0K�[0K�[36;1mRestoring cache�[0;m�[0;m
�[32;1mChecking cache for 0_package-lock-9ac3d77e7152bd95f87b88dd4e406992591eb253-protected...�[0;m
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.�[0;m 
�[0;33mWARNING: Cache file does not exist                �[0;m 
�[0;33mFailed to extract cache�[0;m
section_end:1718111550:restore_cache
�[0Ksection_start:1718111550:step_script
�[0K�[0K�[36;1mExecuting "step_script" stage of the job script�[0;m�[0;m
�[0KUsing docker image sha256:67d9cdb160166226de55337f6b14c44d576cf14f10cd0fb9fbd7854b04dad8ba for node:20.10.0 with digest node@sha256:8d0f16fe841577f9317ab49011c6d819e1fa81f8d4af7ece7ae0ac815e07ac84 ...�[0;m
�[32;1m$ npm pkg delete scripts.prepare�[0;m
�[32;1m$ echo "Starting to format check the application..."�[0;m
Starting to format check the application...
�[32;1m$ npm run format:check�[0;m

> astro-paper@4.2.0 format:check
> prettier --check . --plugin=prettier-plugin-astro

sh: 1: prettier: not found
section_end:1718111551:step_script
�[0Ksection_start:1718111551:cleanup_file_variables
�[0K�[0K�[36;1mCleaning up project directory and file based variables�[0;m�[0;m
section_end:1718111551:cleanup_file_variables
�[0K�[31;1mERROR: Job failed: exit code 1
�[0;m

@SSmale
Copy link
Contributor Author

SSmale commented Jun 11, 2024

Do you have all the files from the theme, seems like there might be something missing.

Can you provide a link to your repo?

@peterschmidler
Copy link

It's a private Gitlab Server, but I just started from scratch cloning the repo, merging the gitlab-ci branch into master and run the pipeline, so there should be no files missing.

Now the pipeline complains about Unknown command: "npm", which is weird as it all starts with a node docker that should have npm available...

@SSmale
Copy link
Contributor Author

SSmale commented Jun 11, 2024

Might be that you have an issue with the docker image. Maybe try running the commands locally to check they are all still valid on your version

@eerison
Copy link
Contributor

eerison commented Oct 7, 2024

don't you think it could be just a blog post?

Edit: everyone gonna use different ci/cd tool to deploy, IMO it could be a blog post.

@satnaing
Copy link
Owner

Hello @SSmale,

Thank you so much for your contribution! I really appreciate your effort in adding a GitLab CI file. However, at this time, I believe this change might be more suitable as part of a discussion or even a how-to guide for users who want to integrate GitLab with AstroPaper. If you're not planning to create either, I’ll happily redirect users to your blog post.

I’m closing this PR for now, but I’d love to see this idea explored further. Thanks again for your work!

@satnaing satnaing closed this Oct 13, 2024
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