Skip to content

Commit

Permalink
Adding package name concept
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceo committed Jun 3, 2024
1 parent 784dd43 commit 60a6e8a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/create-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@ jobs:
steps:
- name: Verify Event and set env
env:
BUILD_URL: ${{ github.event.client_payload.build_url }}
PR_BRANCH: ${{ github.event.client_payload.branch }}
PACKAGE: ${{ github.event.client_payload.dependency_package }}
PACKAGE_NAME: echo "${{ github.event.client_payload.dependency_package_name }}" | sed 's/[^\/]*\///'

run: |
echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_ENV
echo "BUILD_URL=$BUILD_URL" >> $GITHUB_ENV
echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
BUILD_URL_IS_ACCEPTED=$(echo '${{ vars.ACCEPTED_BUILD_URL_PREFIXES }}' | jq --arg url "${{ env.BUILD_URL }}" 'any(.[]; . as $prefix | $url | contains($prefix))')
echo "BUILD_URL_IS_ACCEPTED=$BUILD_URL_IS_ACCEPTED" >> $GITHUB_ENV
PACKAGE_NAME_IS_VALID=$(echo '${{ vars.ACCEPTED_PACKAGES }}' | jq --arg project "${{ env.PACKAGE }}" 'any(.[]; . as $name | $project | match($name))')
echo "PACKAGE_NAME_IS_VALID=$PACKAGE_NAME_IS_VALID" >> $GITHUB_ENV
if: ${{ github.event.action == 'create_pr' && github.event.client_payload.branch && github.event.client_payload.build_url && github.event.client_payload.dependency_package }}

- name: Stop workflow if any variables are missing
run: |
echo "${{ toJson(env) }}"
echo "::error::Some variable is missing. Have to stop..."
exit 1
if: ${{ !env.PR_BRANCH || !env.BUILD_URL && !env.PACKAGE || !vars.ACCEPTED_BUILD_URL_PREFIXES }}
if: ${{ !env.PR_BRANCH || !env.PACKAGE || !env.PACKAGE_NAME || !vars.PACKAGE_NAME_IS_VALID }}

- name: Stop workflow if build url is not valid
run: |
Expand Down

0 comments on commit 60a6e8a

Please sign in to comment.