0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Removed forced pushed CI check

- we probably just want to run my logic to get the base commit for all
  pushes because otherwise the `base.sha` will be null for new branches
This commit is contained in:
Daniel Lockyer 2023-07-10 14:02:40 +02:00 committed by Daniel Lockyer
parent a5fe87cc4d
commit 389f480c96

View file

@ -40,25 +40,19 @@ jobs:
ref: ${{ env.HEAD_COMMIT }} ref: ${{ env.HEAD_COMMIT }}
fetch-depth: 2 fetch-depth: 2
- name: Get metadata - name: Get metadata (push)
id: get_metadata if: github.event_name == 'push'
run: | run: |
# get base commit for pushes NUMBER_OF_COMMITS=$(jq '.event.commits | length' < '${{ env.GITHUB_CONTEXT }}')
if [ "${{ github.event_name }}" = "push" ]; then echo "There are $NUMBER_OF_COMMITS commits in this push."
if [ -n "${{ github.event.before }}" ]; then echo "BASE_COMMIT=$(git rev-parse HEAD~$NUMBER_OF_COMMITS)" >> $GITHUB_ENV
if [ "${{ github.event.forced }}" = 'true' ]; then
NUMBER_OF_COMMITS=$(printf "%s\n" < '${{ env.GITHUB_CONTEXT }}' | jq '.event.commits | length') - name: Get metadata (pull_request)
echo "BASE_COMMIT=$(git rev-parse HEAD~$NUMBER_OF_COMMITS)" >> $GITHUB_ENV if: github.event_name == 'pull_request'
else run: |
# only set the base commit if it wasn't a force push (we can't get the base commit in that case) BASE_COMMIT=$(curl --location --request GET 'https://api.github.com/repos/TryGhost/Ghost/pulls/${{ github.event.pull_request.number }}' --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r .base.sha)
echo "BASE_COMMIT=${{ github.event.before }}" >> $GITHUB_ENV echo "Setting BASE_COMMIT to $BASE_COMMIT"
fi echo "BASE_COMMIT=$BASE_COMMIT" >> $GITHUB_ENV
fi
else
# get base commit for PRs
BASE_COMMIT=$(curl --location --request GET 'https://api.github.com/repos/TryGhost/Ghost/pulls/${{ github.event.pull_request.number }}' --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq .base.sha | tr -d '"')
echo "BASE_COMMIT=$BASE_COMMIT" >> $GITHUB_ENV
fi
- name: Determine changed packages - name: Determine changed packages
uses: AurorNZ/paths-filter@v3.0.1 uses: AurorNZ/paths-filter@v3.0.1