Skip to content

Commit

Permalink
Merge github-issue workflow in main workflow #134 (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Feb 13, 2024
1 parent 93cf75a commit bfbfa15
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
40 changes: 39 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,44 @@ jobs:
echo "image_tag=${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
echo "image_name=cyberdojo/dashboard:${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
ticket:
needs: [kosli-trail]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Kosli CLI
uses: kosli-dev/setup-cli-action@v2
with:
version: ${{ vars.KOSLI_CLI_VERSION }}

- name: Check git-commit message references a Github Issue
run: |
export COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{ github.sha }})
# Issue number can be specified as #1 or gh-1
export GITHUB_ISSUE_NUMBER=$(echo $COMMIT_MESSAGE | grep -oE '(#|gh-)[0-9]+' | head -n 1 | grep -oE '[0-9]+')
HTTP_CODE=$(curl --output /dev/null --location \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--write-out "%{http_code}" \
--silent \
https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${GITHUB_ISSUE_NUMBER})
if [[ ${HTTP_CODE} -eq 200 ]]; then
export KOSLI_COMPLIANT=true
export EXTERNAL_URL="--external-url="issue=https://github.com/${GITHUB_REPOSITORY}/issues/${GITHUB_ISSUE_NUMBER}"
else
export KOSLI_COMPLIANT=false
export EXTERNAL_URL=
fi
kosli attest generic \
--compliant="${KOSLI_COMPLIANT}" \
${EXTERNAL_URL} \
--name=dashboard.ticket
lint:
needs: [kosli-trail]
Expand Down Expand Up @@ -193,7 +231,7 @@ jobs:


sdlc-control-gate:
needs: [lint, pull-request, unit-tests, snyk-scan, kosli-trail, build-image]
needs: [ticket, lint, pull-request, unit-tests, snyk-scan, kosli-trail, build-image]
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ needs.kosli-trail.outputs.image_name }}
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/main_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,45 @@ jobs:
echo "image_name=cyberdojo/dashboard:${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
ticket:
needs: [kosli-trail]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Kosli CLI
uses: kosli-dev/setup-cli-action@v2
with:
version: ${{ vars.KOSLI_CLI_VERSION }}

- name: Check git-commit message references a Github Issue
run: |
export COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{ github.sha }})
# Issue number can be specified as #1 or gh-1
export GITHUB_ISSUE_NUMBER=$(echo $COMMIT_MESSAGE | grep -oE '(#|gh-)[0-9]+' | head -n 1 | grep -oE '[0-9]+')
HTTP_CODE=$(curl --output /dev/null --location \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--write-out "%{http_code}" \
--silent \
https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${GITHUB_ISSUE_NUMBER})
if [[ ${HTTP_CODE} -eq 200 ]]; then
export KOSLI_COMPLIANT=true
export EXTERNAL_URL="--external-url="issue=https://github.com/${GITHUB_REPOSITORY}/issues/${GITHUB_ISSUE_NUMBER}"
else
export KOSLI_COMPLIANT=false
export EXTERNAL_URL=
fi
kosli attest generic \
--compliant="${KOSLI_COMPLIANT}" \
${EXTERNAL_URL} \
--name=dashboard.ticket
lint:
needs: [kosli-trail]
runs-on: ubuntu-latest
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions .kosli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ trail:
artifacts:
- name: dashboard
attestations:
- name: ticket
type: generic
- name: lint
type: generic
- name: pull-request
Expand Down

0 comments on commit bfbfa15

Please sign in to comment.