Skip to content

Instantly share code, notes, and snippets.

@geodis
Last active September 8, 2023 10:02
Show Gist options
  • Save geodis/3079279b3e0de0007ecbd3fb428af46f to your computer and use it in GitHub Desktop.
Save geodis/3079279b3e0de0007ecbd3fb428af46f to your computer and use it in GitHub Desktop.
GithubActions

Here’s a shorter list of 10 important GitHub Actions environment variables:

  1. GITHUB_WORKSPACE - The default working directory for steps and location of your repo.
  2. GITHUB_ACTOR - The name of the person or app that initiated the workflow.
  3. GITHUB_REPOSITORY - The owner and repository name.
  4. GITHUB_EVENT_NAME - The name of the event that triggered the workflow.
  5. GITHUB_SHA - The commit SHA that triggered the workflow.
  6. GITHUB_REF - The branch or tag ref that triggered the workflow.
  7. GITHUB_JOB - The ID of the current job.
  8. GITHUB_RUN_NUMBER - A unique number for each run of a workflow.
  9. GITHUB_WORKFLOW - The name of the workflow.
  10. RUNNER_OS - The OS of the runner executing the job (Linux, Windows, macOS).

Como setear un environment

Para utilizar las variables que se pueden declarar declarar en la UI

jobs:
  set_environment:
    outputs:
      environment_name: ${{ steps.branch_name.outputs.branch }}
    runs-on: ubuntu-latest
    steps:
    - name: Get branch name
      id: branch_name
      run: echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"

  build_and_publish:
    name: "Build and Publish to ECR"
    needs: set_environment
    runs-on: ubuntu-latest
    environment:
      name: ${{ needs.set_environment.outputs.environment_name}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment