From 9565e80fb63f60b546929358d8ff6cd74c70d8aa Mon Sep 17 00:00:00 2001 From: the-forest-tree Date: Thu, 21 Sep 2023 10:20:19 +0000 Subject: [PATCH] ci: replace old author_association logic with protected Github Environments --- .github/workflows/hrflow_connectors.yml | 38 ++----------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/.github/workflows/hrflow_connectors.yml b/.github/workflows/hrflow_connectors.yml index 213719cf4..acb6c9909 100644 --- a/.github/workflows/hrflow_connectors.yml +++ b/.github/workflows/hrflow_connectors.yml @@ -19,20 +19,8 @@ jobs: core-tests: runs-on: ubuntu-latest if: github.event.commits[0].author.name != 'hrflow-semantic-release' + environment: ci steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github.event) }} - run: | - echo "$GITHUB_CONTEXT" - - - name: Check permissions for job - if: ${{ !( (github.event_name == 'push' && github.ref == 'refs/heads/master') || contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.pull_request.author_association) || contains(github.event.pull_request.labels.*.name, 'run tests for fork'))}} - uses: actions/github-script@v3 - with: - script: | - core.setFailed("Not enough permissions to run Core Tests") - - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} @@ -116,15 +104,9 @@ jobs: connectors-integration-tests: runs-on: ubuntu-latest if: github.event.commits[0].author.name != 'hrflow-semantic-release' + environment: ci needs: [core-tests] steps: - - name: Check permissions for job - if: ${{ !( (github.event_name == 'push' && github.ref == 'refs/heads/master') || contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.pull_request.author_association) || contains(github.event.pull_request.labels.*.name, 'run tests for fork')) }} - uses: actions/github-script@v3 - with: - script: | - core.setFailed("Not enough permissions to run Integration Tests") - - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} @@ -178,22 +160,6 @@ jobs: HRFLOW_CONNECTORS_STORE_ENABLED: "1" HRFLOW_CONNECTORS_LOCALJSON_DIR: "/tmp/" - reset-labels: - runs-on: ubuntu-latest - if: github.event.commits[0].author.name != 'hrflow-semantic-release' - needs: [core-tests, connectors-integration-tests] - permissions: - issues: write - pull-requests: write - steps: - - name: Remove run tests for fork label - run: | - curl \ - -X DELETE \ - -H 'Accept: application/vnd.github.v3+json' \ - -H 'Authorization: token ${{ github.token }}' \ - 'https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels/run%20tests%20for%20fork' - cd: runs-on: ubuntu-latest if: github.event.commits[0].author.name != 'hrflow-semantic-release' && github.event_name == 'push' && github.ref == 'refs/heads/master'