Skip to content

Commit

Permalink
[chore] Use env vars when running shell commands in CI (#8177)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski authored Aug 4, 2023
1 parent 8aeb3ab commit 92d6a9f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
29 changes: 16 additions & 13 deletions .github/workflows/api-compatibility.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This GitHub action is used to compare API state snapshots of Main
# to Head of the PR in order to validate releases are not breaking
# backwards compatibility.
# to Head of the PR in order to validate releases are not breaking
# backwards compatibility.
#
# This GitHub action will fail if there are incompatible changes.
#
Expand All @@ -15,44 +15,47 @@ on:
jobs:
Check-Compatibility:
runs-on: macos-latest
env:
BASE_REF: ${{ github.base_ref }}
HEAD_REF: ${{ github.head_ref }}
steps:

- name: Checkout-Main
uses: actions/checkout@v3
with:
with:
ref: ${{ github.base_ref }}
path: ${{ github.base_ref }}

- name: Checkout-HEAD
uses: actions/checkout@v3
with:
uses: actions/checkout@v3
with:
path: ${{ github.head_ref }}

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ~1.19.12

# Generate apidiff states of Main
- name: Generate-States
run: |
cd ${{ github.base_ref }}
cd $BASE_REF
make apidiff-build
# Compare apidiff states of Main with PR
- name: Compare-States
env:
env:
CI: true
COMPARE_OPTS: -d "../${{ github.base_ref }}/internal/data/apidiff"
run: |
cd ${{ github.head_ref }}
cd $HEAD_REF
make apidiff-compare
# Fail GitHub Action if there are incompatible changes
- name: Check-States
env:
env:
CI: true
COMPARE_OPTS: -d "../${{ github.base_ref }}/internal/data/apidiff" -c
run: |
cd ${{ github.head_ref }}
cd $HEAD_REF
make apidiff-compare
6 changes: 4 additions & 2 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependencies') && !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') && !contains(github.event.pull_request.title, '[chore]')}}

env:
PR_HEAD: ${{ github.event.pull_request.head.sha }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand All @@ -39,7 +41,7 @@ jobs:

- name: Ensure no changes to the CHANGELOG.md or CHANGELOG-API.md
run: |
if [[ $(git diff --name-only $(git merge-base origin/main ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} ./CHANGELOG*.md) ]]
if [[ $(git diff --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./CHANGELOG*.md) ]]
then
echo "CHANGELOG.md and CHANGELOG-API.md should not be directly modified."
echo "Please add a .yaml file to the ./.chloggen/ directory."
Expand All @@ -52,7 +54,7 @@ jobs:
- name: Ensure ./.chloggen/*.yaml addition(s)
run: |
if [[ 1 -gt $(git diff --diff-filter=A --name-only $(git merge-base origin/main ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} ./.chloggen | grep -c \\.yaml) ]]
if [[ 1 -gt $(git diff --diff-filter=A --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./.chloggen | grep -c \\.yaml) ]]
then
echo "No changelog entry was added to the ./.chloggen/ directory."
echo "Please add a .yaml file to the ./.chloggen/ directory."
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
changedfiles:
name: changed files
runs-on: ubuntu-latest
env:
PR_HEAD: ${{ github.event.pull_request.head.sha }}
outputs:
md: ${{ steps.changes.outputs.md }}
steps:
Expand All @@ -26,7 +28,7 @@ jobs:
- name: Get changed files
id: changes
run: |
echo "md=$(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base origin/main ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} | grep .md$ | xargs)" >> $GITHUB_OUTPUT
echo "md=$(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base origin/main $PR_HEAD) $PR_HEAD | grep .md$ | xargs)" >> $GITHUB_OUTPUT
check-links:
runs-on: ubuntu-latest
needs: changedfiles
Expand Down

0 comments on commit 92d6a9f

Please sign in to comment.