{"id":20667901,"url":"https://github.com/statnmap/gitlab-pages-deploy","last_synced_at":"2025-10-17T16:05:26.296Z","repository":{"id":117562924,"uuid":"434189456","full_name":"statnmap/GitLab-Pages-Deploy","owner":"statnmap","description":"Bash to deploy GitLab Pages in a branch like gh-pages","archived":false,"fork":false,"pushed_at":"2022-09-06T16:41:32.000Z","size":33,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-19T19:24:59.357Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/statnmap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-12-02T11:14:21.000Z","updated_at":"2022-11-16T12:01:47.000Z","dependencies_parsed_at":"2024-06-08T10:00:10.668Z","dependency_job_id":null,"html_url":"https://github.com/statnmap/GitLab-Pages-Deploy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/statnmap/GitLab-Pages-Deploy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statnmap%2FGitLab-Pages-Deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statnmap%2FGitLab-Pages-Deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statnmap%2FGitLab-Pages-Deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statnmap%2FGitLab-Pages-Deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/statnmap","download_url":"https://codeload.github.com/statnmap/GitLab-Pages-Deploy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statnmap%2FGitLab-Pages-Deploy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259650959,"owners_count":22890385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T19:45:30.651Z","updated_at":"2025-10-17T16:05:21.261Z","avatar_url":"https://github.com/statnmap.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitLab-Pages-Deploy  \nBash to deploy GitLab Pages in a branch like gh-pages  \n_(Highly inspired from https://github.com/marketplace/actions/gh-pages-deploy)_\n\nIt allows to keep track of modifications between to publications\n\n- This creates a branch named \"gh-pages\"\n- This stores the content of your branch \"public/\" directory inside\n\nAlso, if you want to be able to render the website for some specific branches, without deleting the 'main' one, you can use sub-website build. See [Publish one sub-website for each branch](https://github.com/statnmap/GitLab-Pages-Deploy#publish-one-site-for-each-branch)\n\n## Demo\n\nYou can find repository with a demo for this script: https://gitlab.com/statnmap/gitlab-pages-demo/-/blob/main/README.md  \nYou'll see Pages with sub-folders of the HTML output for each branch that is worth it.  \n\n## Prepare the \"gitlab-ci.yml\"\nOn GitLab, you can choose to publish the \"gh-pages\" branch instead of the public artifacts using this in the \".gitlab-ci.yml\":\n\n```yaml\ngh-pages-prep:\n    stage: prepare-deploy\n    only:\n      - main\n    script:\n      # Deploy a unique site in gh-pages branch,\n      # or a sub-website for each branch if SITE_BY_BRANCH: \"TRUE\"\n      - wget https://raw.githubusercontent.com/statnmap/GitLab-Pages-Deploy/main/deploy_pages_branch.sh\n      - /bin/bash deploy_pages_branch.sh\n      \npages:\n    stage: deploy\n    script:\n        - echo \"deploy\"\n    artifacts:\n        paths:\n            - public\n    only:\n        # Because we use \"deploy_pages_branch\", only gh-pages branch needs to be deployed\n        # All outputs from other branches in \"prepare-deploy\" step will push in \"gh-pages\"\n        - gh-pages\n```\n\nAlso think about using `except: gh-pages` in your other stages because no file is available for this branch.\n\n## Create your token to allow push\n\n### Create New project token  \n\n- Go to: Settings \u003e Access Token\n  - If it is not activated, use a personal access token: https://gitlab.com/-/profile/personal_access_tokens\n- Choose a proper name to recognize it when you'll want to revoke it\n- Choose role as \"Developer\"\n- Check access: read_repository and write_repository\n- Save your token, you will only see it once\n\n\u003cimg src=\"https://user-images.githubusercontent.com/21193866/144649526-59017727-a804-48c0-934c-8306d2059f36.png\" alt=\"drawing\" width=\"600\"/\u003e\n\n### Add token in the CI/CD variables as `PROJECT_ACCESS_TOKEN`\n\n- Go to: Settings \u003e CI/CD \u003e Variables\n- Expand the section\n- Add variable\n- Fill key with `PROJECT_ACCESS_TOKEN`\n- Fill the token with the one you saved above\n- Mask variable but you can uncheck Protect variable\n- Add variable\n\n\u003cimg src=\"https://user-images.githubusercontent.com/21193866/144649687-d18ce555-827e-44ad-82e8-dfb7f3966bec.png\" alt=\"PROJECT_ACCESS_TOKEN\" width=\"600\"/\u003e\n\n\n## Publish one sub-website for each branch\n\nIf you use the environment variable :\n```yaml\nvariables:\n  SITE_BY_BRANCH: \"TRUE\"\n  \n gh-pages-prep:\n    stage: prepare-deploy\n    only:\n      - master\n      - main\n      - production\n      - validation\n    script:\n      # Deploy a unique site in gh-pages branch,\n      # or a sub-website for each branch if SITE_BY_BRANCH: \"TRUE\"\n      - wget https://raw.githubusercontent.com/statnmap/GitLab-Pages-Deploy/main/deploy_pages_branch.sh\n      - /bin/bash deploy_pages_branch.sh\n      \npages:\n    stage: deploy\n    script:\n        - echo \"deploy\"\n    artifacts:\n        paths:\n            - public\n    only:\n        # Because we use \"deploy_pages_branch\", only gh-pages branch needs to be deployed\n        # All outputs from other branches in \"prepare-deploy\" step will push in \"gh-pages\"\n        - gh-pages\n```\n\nThe 'gh-pages' branch will keep site content of other published branches in a dedicated subdirectory.  \nThis will then create an index file at the root of your website to let you choose which version you want to see.\n\n```html\n\u003ch2\u003eIndex of branch directories\u003c/h2\u003e\n\n- index.html\n- master\n- production\n- validation\n- other-branch\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatnmap%2Fgitlab-pages-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatnmap%2Fgitlab-pages-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatnmap%2Fgitlab-pages-deploy/lists"}