Skip to content

Test wrong status

Test wrong status #51

name: Test wrong status
on:
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered
# #
# # Added pull_request to register workflow from the PR.
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo
# pull_request: {}
workflow_dispatch:
inputs:
ref:
description: "The fully-formed ref of the branch or tag that triggered the workflow run"
required: false
type: "string"
sha:
description: "The sha of the commit that triggered the workflow run"
required: false
type: "string"
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Setup
run: echo "Do setup"
- id: random
shell: bash
run: |-
echo "password=$(echo $RANDOM | md5sum | head -c 20)" >> $GITHUB_OUTPUT
echo "environment=$(echo $RANDOM | md5sum | head -c 20)" >> $GITHUB_OUTPUT
outputs:
random: ${{ steps.random.outputs.password }}
environment: ${{ steps.random.outputs.environment }}
set_status:
runs-on: ubuntu-latest
needs: [setup]
steps:
- name: Sleep for 10s
uses: juliangruber/[email protected]
with:
time: 30s
- name: Set status
uses: myrotvorets/set-commit-status-action@master
with:
repo: ${{ github.repository }}
sha: ${{ github.sha }}
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
status: pending
context: continuous-delivery/${{ needs.setup.outputs.environment }}.test-app
test:
runs-on: ubuntu-latest
continue-on-error: true
needs: [setup]
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: ./
id: current
with:
repository: ${{ github.repository }}
sha: ${{ github.sha }}
status: continuous-delivery/${{ needs.setup.outputs.environment }}.test-app
expected_state: "success"
token: ${{ github.token }}
outputs:
status: ${{ steps.current.outcome }}
assert:
runs-on: ubuntu-latest
needs: [test, set_status]
steps:
- uses: nick-fields/assert-action@v1
with:
expected: "failure"
actual: "${{ needs.test.outputs.status }}"
teardown:
runs-on: ubuntu-latest
needs: [assert, setup]
if: ${{ always() }}
steps:
- name: Set status
uses: myrotvorets/set-commit-status-action@master
with:
repo: ${{ github.repository }}
sha: ${{ github.sha }}
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
status: success
context: continuous-delivery/${{ needs.setup.outputs.environment }}.test-app