You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove the need for custom environment variables in GitHub actions
Context
Our GitHub actions currently rely on the following environment variables:
GITHUB_BASE_REF
GITHUB_DEFAULT_BRANCH
GITHUB_EVENT_NAME
GITHUB_PUSH_BASE_SHA
GITHUB_PUSH_BEFORE_SHA
GITHUB_SHA
Their names are a bit deceiving though: not all of them are defined in GitHub CI environment. GITHUB_DEFAULT_BRANCH, GITHUB_PUSH_BASE_SHA and GITHUB_PUSH_BEFORE_SHA are not. These 3 variables must be defined by all users of our actions using the env: key, like this:
name: GitGuardian scanon: [push, pull_request]jobs:
scanning:
name: GitGuardian scanruns-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@v2with:
fetch-depth: 0# fetch all history so multiple commits can be scanned
- name: GitGuardian scanuses: GitGuardian/[email protected]env:
GITHUB_PUSH_BEFORE_SHA: ${{ github.event.before }}GITHUB_PUSH_BASE_SHA: ${{ github.event.base }}GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
Goal
The goal of this issue is to remove the need for these 3 variables. The variables initialize themselves from the GitHub event object. This object is serialized as a .json file whose path is in GITHUB_EVENT_PATH. This means we can read it and initialize our variables from it.
Definition of Done
Our GitHub action code no longer requires our users to define GITHUB_PUSH_BEFORE_SHA, GITHUB_PUSH_BASE_SHA or GITHUB_DEFAULT_BRANCH;
For consistency, it would be good to read all variables from the .json file;
The action documentation has been updated accordingly. Note: this documentation update must only be published after the changes have been released!
The text was updated successfully, but these errors were encountered:
Remove the need for custom environment variables in GitHub actions
Context
Our GitHub actions currently rely on the following environment variables:
Their names are a bit deceiving though: not all of them are defined in GitHub CI environment. GITHUB_DEFAULT_BRANCH, GITHUB_PUSH_BASE_SHA and GITHUB_PUSH_BEFORE_SHA are not. These 3 variables must be defined by all users of our actions using the
env:
key, like this:Goal
The goal of this issue is to remove the need for these 3 variables. The variables initialize themselves from the GitHub event object. This object is serialized as a .json file whose path is in GITHUB_EVENT_PATH. This means we can read it and initialize our variables from it.
Definition of Done
The text was updated successfully, but these errors were encountered: