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

[feature] Add a $gitHash token #1639

Closed
rhuanbarreto opened this issue Sep 4, 2024 · 2 comments
Closed

[feature] Add a $gitHash token #1639

rhuanbarreto opened this issue Sep 4, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@rhuanbarreto
Copy link

Is your feature request related to a problem? Please describe.

Many times we need to use commit sha's to fill up some info in the applications developed. For example, we use the commit SHA as the version in the deployed frontends and backends.

Today we need to reuse the COMMIT_SHA env variable from the CI run:

tasks:
  build-frontend:
    platform: bun
    command: bun --bun run vite build
    inputs:
      - "@group(sources)"
    outputs:
      - dist
    type: build
    deps:
      - build
      - lint
      - format-check
      - test
    env:
      NODE_ENV: production
      VITE_SENTRY_RELEASE: ${COMMIT_SHA}

In Github actions for the PR we pass it as an env:

- name: Build and Deploy
  run: moon ci
  env:
    COMMIT_SHA: ${{ github.event.pull_request.head.sha }}

Or in the main branch:

- name: Deploy
  run: moon run :deploy
  env:
    COMMIT_SHA: ${{ github.sha }}

But locally if I'm running moon ci it would be way more beneficial to have this as a token ($gitHash and $gitHashShort) so moon could infer this to me by running:

git rev-parse HEAD

Then I wouldn't need to setup this in CI and locally. Moon would be smart enough to fill this up for me so I could use.

Describe the solution you'd like

Adding 2 tokens $gitHash and $gitHashShort so I could use them in the tasks.yaml file like this:

tasks:
  build-frontend:
    platform: bun
    command: bun --bun run vite build
    inputs:
      - "@group(sources)"
    outputs:
      - dist
    type: build
    deps:
      - build
      - lint
      - format-check
      - test
    env:
      NODE_ENV: production
      VITE_SENTRY_RELEASE: $gitHash

Describe alternatives you've considered

Today I inject myself during CI.

@rhuanbarreto rhuanbarreto added the enhancement New feature or request label Sep 4, 2024
@milesj
Copy link
Collaborator

milesj commented Sep 4, 2024

I like this. The token layer currently has no access to the vcs layer, so I'll have to figure something out here.

@milesj
Copy link
Collaborator

milesj commented Nov 26, 2024

Added $vcsRevision in v1.30.

@milesj milesj closed this as completed Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants