{"id":16000778,"url":"https://github.com/zero88/gh-project-context","last_synced_at":"2025-03-16T06:33:10.953Z","repository":{"id":38354235,"uuid":"323307055","full_name":"zero88/gh-project-context","owner":"zero88","description":"Query and update Project context","archived":false,"fork":false,"pushed_at":"2024-10-23T16:10:16.000Z","size":3401,"stargazers_count":2,"open_issues_count":18,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-23T22:03:22.013Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zero88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-12-21T10:48:30.000Z","updated_at":"2024-08-05T12:29:24.000Z","dependencies_parsed_at":"2024-01-18T14:46:00.983Z","dependency_job_id":"1706f599-00d2-4d34-9a77-6e64108190e9","html_url":"https://github.com/zero88/gh-project-context","commit_stats":{"total_commits":91,"total_committers":3,"mean_commits":"30.333333333333332","dds":0.1648351648351648,"last_synced_commit":"8c7217609fb3d6a9f4ccab0ab8214ad6151aef9f"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero88%2Fgh-project-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero88%2Fgh-project-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero88%2Fgh-project-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero88%2Fgh-project-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zero88","download_url":"https://codeload.github.com/zero88/gh-project-context/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221661155,"owners_count":16859489,"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-10-08T09:20:32.864Z","updated_at":"2024-10-27T10:07:12.978Z","avatar_url":"https://github.com/zero88.png","language":"TypeScript","readme":"# gh-project-context\n\n![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/zero88/gh-project-context?sort=semver\u0026style=flat-square)\n\nBuild project context and correct Project version in any language version before release.\n\nThis action is build a Project context depends on GitHub event to make decision in further step, e.g: do build, do test,\ndo analysis, do tag, do release based on your workflow model.\n\nIt also verifies and corrects automatically Project version in metadata file in `release pull request` or `tag`:\n\n- NodeJS: `package.json`\n- Java: Gradle with `gradle.properties`\n- Python: `Poetry` with `pyproject.toml` or `version.py`\n- Plain text: `VERSION.txt`\n- Or any version metadata file if you know some magical regex skill\n\n## Usage\n\n### Trigger precondition\n\nThe usual example\n\n```yaml\non:\n  create:\n    branches: [ 'release/**' ] ## To create a release PR\n  push:\n    branches: ## On main branch, hotfix branch and/or all release branches (optional) \n      - main\n      - hotfix/**\n      - release/**\n    tags: [ 'v*' ] ## Release tag version\n    paths-ignore:\n      - '.github/ISSUE_TEMPLATE/**'\n      - '.github/*.yml'\n      - 'LICENSE'\n  pull_request:\n    types: [ opened, synchronize, reopened, closed ]\n    branches:\n      - main\n      - hotfix/**\n    paths-ignore:\n      - '.github/ISSUE_TEMPLATE/**'\n      - '.github/*.yml'\n      - 'LICENSE'\n```\n\nMore detailed at [GitHub docs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on)\n\n### Integrate the action in your workflow\n\nYou can use this action in 2 ways:\n\n1. Add it as first `job` in your `workflow`\n\n  ```yaml\n  jobs:\n    context:\n      runs-on: ubuntu-latest\n      outputs:\n        branch: ${{ steps.context.outputs.branch }}\n        shouldBuild: ${{ steps.context.outputs.decision_build }}\n        shouldPublish: ${{ steps.context.outputs.decision_publish }}\n        isRelease: ${{ steps.context.outputs.isTag \u0026\u0026 steps.context.outputs.isRelease }}\n        version: ${{ steps.context.outputs.version }}\n        commitId: ${{ steps.context.outputs.commitShortId }}\n        semanticVersion: ${{ steps.semantic.outputs.semanticVersion }}\n\n      steps:\n        - uses: actions/checkout@v3\n        - name: Project context\n          id: context\n          uses: zero88/gh-project-context@v2\n\n    build:\n      runs-on: ubuntu-latest\n      needs: context\n      if: needs.context.outputs.shouldBuild == 'true' # condition to build\n  ```\n\n2. Add it as `step` in your `job`\n\n  ```yaml\n  jobs:\n    matrix:\n      runs-on: ubuntu-latest\n      steps:\n        - uses: actions/checkout@v2\n        - name: Project context\n          uses: zero88/gh-project-context@v1\n          id: project_context\n        - name: Build project\n          if: steps.project_context.outputs.decision_build == 'true' # condition to build\n          shell: bash\n          runs: |\n            npm ci\n            npm run build\n        - name: Build project\n          if: steps.project_context.outputs.decision_publish == 'true' # condition to publish\n          shell: bash\n          runs: |\n            npm publish\n  ```\n\n### Action output\n\n```shell\nRun zero88/gh-project-context@v1.2\nLoading...\n[CI::Process] Evaluate context on main\n  Searching version in file...\n  Current Version: 0.0.3\n\nProject context\nVersion context\n  {\n    \"branch\": \"main\",\n    \"current\": \"0.0.3\",\n    \"version\": \"0.0.3\"\n  }\nCI context\n  {\n    \"isPushed\": false\n  }\nCI decision\n  {\n    \"build\": true,\n    \"publish\": true\n  }\nAction Output\n  {\n    \"branch\": \"main\",\n    \"onDefaultBranch\": true,\n    \"isBranch\": true,\n    \"isPR\": false,\n    \"isTag\": false,\n    \"isSchedule\": false,\n    \"isDispatch\": false,\n    \"isAfterMergedReleasePR\": false,\n    \"isClosed\": false,\n    \"isMerged\": false,\n    \"isOpened\": false,\n    \"isRelease\": false,\n    \"commitId\": \"c1c69ba9f41eeffaf260b7a6174fc37493c8fb42\",\n    \"commitMsg\": \"chore: bump to next version\",\n    \"commitShortId\": \"c1c69ba\",\n    \"ci_isPushed\": false,\n    \"decision_build\": true,\n    \"decision_publish\": true,\n    \"version\": \"0.0.3\",\n    \"versions_branch\": \"main\",\n    \"versions_current\": \"0.0.3\"\n  }\n```\n\n## Input and Output\n\n### Input\n\n| Name                  | Description                                                                                                                | Required | Default value                                                |\n|-----------------------|----------------------------------------------------------------------------------------------------------------------------|----------|--------------------------------------------------------------|\n| defaultBranch         | Project default branch                                                                                                     | false    | `main`                                                       |\n| tagPrefix             | Tag Prefix                                                                                                                 | false    | `v`                                                          |\n| releaseBranchPrefix   | Git Release Branch Prefix                                                                                                  | false    | `release/`                                                   |\n| hotfixPrefix          | Git Hotfix Prefix                                                                                                          | false    | `hotfix/`                                                    |\n| mergedReleaseMsgRegex | Merged release message regex                                                                                               | false    | `^Merge pull request #[0-9]+ from .+/release/.+$`            |\n| patterns              | The patterns to search/replace a version.\u003cbr\u003eE.g: `\u003cglob_pattern_with_ext\u003e::\u003cregex_group\u003e::\u003cversion_regex\u003e`                | false    | See [below](#default-pattern-input)                          |\n| shaLength             | Create output short commit id within length                                                                                | false    | `7`                                                          |\n| allowCommit           | CI: Allow git commit to fix version if not match                                                                           | false    | `true`                                                       |\n| allowTag              | CI: Allow git tag if merged release branch                                                                                 | false    | `true`                                                       |\n| userName              | CI: Username to commit                                                                                                     | false    | `ci-bot`                                                     |\n| userEmail             | CI: User email to commit                                                                                                   | false    | `actions@github.com`                                         |\n| mustSign              | CI: Required GPG sign when git commit/tag                                                                                  | false    | `false`                                                      |\n| prefixCiMsg           | CI: Prefix bot message                                                                                                     | false    | `\u003cci-auto-commit\u003e`                                           |\n| correctVerMsg         | CI: Correct version message template                                                                                       | false    | `Correct version`                                            |\n| releaseVerMsg         | CI: Release version message template                                                                                       | false    | `Release version`                                            |\n| nextVerMsg            | CI: Next version message template                                                                                          | false    | `Next version`                                               |\n| nextVerMode           | CI: Next version mode to choose for upgrading version after merged release PR. One of: MAJOR,MINOR,PATCH,NONE              | false    | `NONE`                                                       |\n| token                 | CI: GitHub token to create a new Release Pull Request                                                                      | false    | ``                                                           |\n| dry                   | CI: Dry run. If `true`, action will run without do modify files or git push or git tag                                     | false    | `false`                                                      |\n| changelog             | Enable generate CHANGELOG                                                                                                  | false    | `false`                                                      |\n| changelogImage        | CHANGELOG docker image tag: https://github.com/github-changelog-generator/docker-github-changelog-generator                | false    | `githubchangeloggenerator/github-changelog-generator:1.16.2` |\n| changelogConfigFile   | CHANGELOG config file: https://github.com/github-changelog-generator/github-changelog-generator#params-file                | false    | `.github_changelog_generator`                                |\n| changelogToken        | CHANGELOG token to query GitHub API: https://github.com/github-changelog-generator/github-changelog-generator#github-token | false    |                                                              |\n| changelogMsg          | CI: Changelog generator commit message template                                                                            | false    | `Generated CHANGELOG`                                        |\n\n#### Default Pattern Input\n\n```\npyproject.toml::(version\\s?=\\s?)(\")([^\"]+)(\")::2\npackage?(-lock).json::(\"version\"\\s?:\\s?)(\")([^\"]+)(\")::2\n@(gradle|maven|pom|project).properties::(version\\s?=\\s?)(.+)::1\n@(application|version).yml::(version:\\s)(.+)::1\n@(VERSION|version)?(.txt)::.+::0\n```\n\n### Output\n\nProject context based on current `GitHub event`\n\n| Name                     | Description                                                                                                                                                                                      |\n|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| branch                   | Current branch name or tag name                                                                                                                                                                  |\n| onDefaultBranch          | Check whether current event is on default branch or not                                                                                                                                          |\n| onRelease                | Check whether current event is on release or not, that means `isRelease \u0026\u0026 isTag`                                                                                                                |\n| isBranch                 | Check whether current event is on branch or not                                                                                                                                                  |\n| isPR                     | Check whether current event is on pull request or not                                                                                                                                            |\n| isTag                    | Check whether current event is on ref tag                                                                                                                                                        |\n| isSchedule               | Check whether current event is by schedule or not                                                                                                                                                |\n| isDispatch               | Check whether current event is by manual or dispatch from another workflow or event from repository                                                                                              |\n| isRelease                | Check whether current event is release event on regardless of branch, pull-request or tag                                                                                                        |\n| isHotfix                 | Check whether current event is hotfix event on regardless of branch, pull-request or tag                                                                                                         |\n| isAfterMergedReleasePR   | Check whether current event is a merged commit after merged release pull request into default branch or not                                                                                      |\n| isMerged                 | Check whether current event is merged PR                                                                                                                                                         |\n| isClosed                 | Check whether current event is close PR but not merged into target branch                                                                                                                        |\n| isOpened                 | Check whether current event is open PR or create branch                                                                                                                                          |\n| prBaseBranch             | Base branch in pull request                                                                                                                                                                      |\n| commitMsg                | The latest commit message                                                                                                                                                                        |\n| commitId                 | The latest commit id                                                                                                                                                                             |\n| commitShortId            | The latest short commit id                                                                                                                                                                       |\n| version                  | Current tag version or release version                                                                                                                                                           |\n| ci_mustFixVersion        | CI: Need to fix version to match with release name                                                                                                                                               |\n| ci_needPullRequest       | CI: Need to open new pull request for release or merge hotfix into default branch                                                                                                                |\n| ci_needTag               | CI: Need to tag new version if release branch is merged                                                                                                                                          |\n| ci_needUpgrade           | CI: Need to upgrade next version after release branch is merged into default branch                                                                                                              |\n| ci_isPushed              | CI: Check whether if auto commit is pushed to remote                                                                                                                                             |\n| ci_commitId              | CI: auto commit id                                                                                                                                                                               |\n| ci_commitMsg             | CI: auto commit message                                                                                                                                                                          |\n| ci_changelog_generated   | CI: changelog is generated                                                                                                                                                                       |\n| ci_changelog_releaseTag  | CI: changelog generated for release tag                                                                                                                                                          |\n| ci_changelog_sinceTag    | CI: changelog generated since tag                                                                                                                                                                |\n| ci_changelog_isCommitted | CI: changelog is committed                                                                                                                                                                       |\n| ci_changelog_commitId    | CI: changelog auto commit id                                                                                                                                                                     |\n| ci_changelog_commitMsg   | CI: changelog auto commit message                                                                                                                                                                |\n| decision_build           | Decision: Should run the next step: such as build \u0026 test. \u003cbr/\u003eDefault value: `!(ciPushed \\|\\| isClosed \\|\\| isMerged \\|\\| (isBranch \u0026\u0026 (isRelease \\|\\| isOpened)) \\|\\| isAfterMergedReleasePR)` |\n| decision_publish         | Should publish artifact: such as push artifact to any registry. \u003cbr/\u003eDefault value: `decision.build \u0026\u0026 (onDefaultBranch \\|\\| (isRelease \u0026\u0026 isTag))`                                              |\n| ver_current              | Current version in config file                                                                                                                                                                   |\n| ver_bumped               | Bumped version                                                                                                                                                                                   |\n| ver_nextMajor            | Suggest next major version if after release and `ver_current` is compatible with semver                                                                                                          |\n| ver_nextMinor            | Suggest next minor version if after release and `ver_current` is compatible with semver                                                                                                          |\n| ver_nextPatch            | Suggest next patch version if after release and `ver_current` is compatible with semver                                                                                                          |\n\n## Note\n\n### Latest commit message\n\n`commitMsg` is not available by default when synchronize/open `pull-request`. In case, you want to use the latest commit\nmessage in `pull-request`, need to tweak your build as below:\n\n```yaml\n- uses: actions/checkout@v2\n  with:\n    token: ${{ secrets.YOUR_GITHUB_TOKEN }}\n    fetch-depth: 2\n- uses: zero88/gh-project-context@v2\n```\n\n## Use Cases\n\nTBD\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero88%2Fgh-project-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzero88%2Fgh-project-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero88%2Fgh-project-context/lists"}