ci: update status when action triggered by issue comment #284
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Check for ansible_managed variable use in comments | |
| on: # yamllint disable-line rule:truthy | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - labeled | |
| issue_comment: | |
| types: | |
| - created | |
| merge_group: | |
| branches: | |
| - main | |
| types: | |
| - checks_requested | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| # This is required for the ability to create/update the Pull request status | |
| statuses: write | |
| jobs: | |
| ansible_managed_var_comment: | |
| if: | | |
| ( | |
| github.event_name == 'issue_comment' | |
| && github.event.issue.pull_request | |
| && (contains(github.event.comment.body, '[citest_all]') | |
| || contains(github.event.comment.body, '[citest_ansible-managed-var-comment]')) | |
| && (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'), | |
| github.event.comment.author_association) | |
| || github.event.comment.user.login == 'systemroller') | |
| ) || ( | |
| github.event_name == 'pull_request' | |
| && github.event.action == 'opened' | |
| && (contains(github.event.pull_request.labels.*.name, 'citest_all') | |
| || contains(github.event.pull_request.labels.*.name, 'citest_ansible-managed-var-comment')) | |
| && (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'), | |
| github.event.pull_request.author_association) | |
| || github.event.pull_request.user.login == 'systemroller') | |
| ) || ( | |
| github.event_name == 'pull_request' | |
| && github.event.action == 'synchronize' | |
| && (contains(github.event.pull_request.labels.*.name, 'citest_all') | |
| || contains(github.event.pull_request.labels.*.name, 'citest_ansible-managed-var-comment')) | |
| && (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'), | |
| github.event.pull_request.author_association) | |
| || github.event.sender.login == 'systemroller') | |
| ) || ( | |
| github.event_name == 'pull_request' | |
| && github.event.action == 'labeled' | |
| && (github.event.label.name == 'citest_all' | |
| || github.event.label.name == 'citest_ansible-managed-var-comment') | |
| && (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'), | |
| github.event.pull_request.author_association) | |
| || github.event.sender.login == 'systemroller') | |
| ) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get PR head SHA and context | |
| if: github.event_name == 'issue_comment' | |
| id: head_sha_context | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| REPO: ${{ github.repository }} | |
| PR_NUMBER: ${{ github.event.issue.number }} | |
| CONTEXT: "${{ github.workflow }} / ${{ github.job }} (pull_request)" | |
| run: | | |
| set -euxo pipefail | |
| head_sha=$(gh api "repos/$REPO/pulls/$PR_NUMBER" --jq '.head.sha') | |
| echo "head_sha=$head_sha" >> "$GITHUB_OUTPUT" | |
| echo "context=$CONTEXT" >> "$GITHUB_OUTPUT" | |
| - name: Set commit status as pending | |
| if: github.event_name == 'issue_comment' | |
| uses: myrotvorets/set-commit-status-action@c0f880c99d91381c6fdb97726f03feb8004409b4 # master | |
| with: | |
| sha: ${{ steps.head_sha_context.outputs.head_sha }} | |
| status: pending | |
| context: ${{ steps.head_sha_context.outputs.context }} | |
| description: Test started | |
| targetUrl: "" | |
| - name: Update pip, git | |
| run: | | |
| set -euxo pipefail | |
| python3 -m pip install --upgrade pip | |
| sudo apt update | |
| sudo apt install -y git | |
| - name: Checkout repo | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| ref: ${{ steps.head_sha_context.outputs.head_sha || github.sha }} | |
| - name: Install tox, tox-lsr | |
| run: | | |
| set -euxo pipefail | |
| pip3 install "git+https://github.com/linux-system-roles/tox-lsr@d594be24ed56e586a5796720d51c261e40c20496" | |
| - name: Run ansible-plugin-scan | |
| run: | | |
| set -euxo pipefail | |
| TOXENV=ansible-managed-var-comment lsr_ci_runtox | |
| - name: Set final commit status | |
| if: always() && github.event_name == 'issue_comment' && steps.head_sha_context.outputs.head_sha != '' | |
| uses: myrotvorets/set-commit-status-action@c0f880c99d91381c6fdb97726f03feb8004409b4 # master | |
| with: | |
| sha: ${{ steps.head_sha_context.outputs.head_sha }} | |
| status: ${{ job.status }} | |
| context: ${{ steps.head_sha_context.outputs.context }} | |
| description: Test finished | |
| targetUrl: "" |