Skip to content

Commit

Permalink
Merge pull request #770 from carstingaxion/feature/playground-preview…
Browse files Browse the repository at this point in the history
…-cleanup

Cleanup workflow from un-thought code
  • Loading branch information
mauteri authored Aug 10, 2024
2 parents 6efa0ae + 33e9c24 commit ddeabdf
Showing 1 changed file with 1 addition and 42 deletions.
43 changes: 1 addition & 42 deletions .github/workflows/playground-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,9 @@ concurrency:

jobs:

needs-build:
name: Check if the pull request was just opened or if PR has changes in /src/ directory
runs-on: ubuntu-latest
outputs:
run_build: ${{ steps.set-run-build.outputs.run_build }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check if zip artifact exists
id: check-artifact
run: |
# Define the expected artifact name based on the repository name and PR
ARTIFACT_NAME="${{ github.event.repository.name }}-pr"
# Use GitHub CLI to check if the artifact exists
ARTIFACT_EXISTS=$(gh api repos/${{ github.repository }}/actions/artifacts --jq ".artifacts[] | select(.name == \"$ARTIFACT_NAME\") | .id" || echo "")
if [ -n "$ARTIFACT_EXISTS" ]; then
# If the artifact exists, set artifact_exists to true
echo "artifact_exists=true" >> $GITHUB_ENV
else
# If the artifact does not exist, set artifact_exists to false
echo "artifact_exists=false" >> $GITHUB_ENV
fi
- name: Set run_build based on artifact existence or /src/ changes
id: set-run-build
run: |
# Check if the artifact does not exist
if [ "${{ steps.check-artifact.outputs.artifact_exists }}" == "false" ]; then
echo "run_build=true" >> $GITHUB_ENV
# Check if there are changes in the /src/ directory using commit SHAs
elif git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -q '^src/'; then
echo "run_build=true" >> $GITHUB_ENV
else
echo "run_build=false" >> $GITHUB_ENV
fi
zip:
name: Build GatherPress plugin & upload as zipped artifact
runs-on: ubuntu-latest
needs: needs-build
if: needs.needs-build.outputs.run_build == 'true' # Only run this job if no built zip-artifact exists or there are changes in /src/
steps:

- name: Checkout
Expand Down Expand Up @@ -109,8 +69,7 @@ jobs:

comment:
name: Comment with playground link
needs: [zip, needs-build] # Ensure this runs after the needs-build & zip jobs.
if: always() # Make sure this job runs even if dependent jobs were skipped.
needs: zip # Ensure this runs after zip job.
runs-on: ubuntu-latest

steps:
Expand Down

0 comments on commit ddeabdf

Please sign in to comment.