Skip to content

Commit

Permalink
Use github context to get repository
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelpasterz committed Dec 1, 2020
1 parent d67725f commit c49b850
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/full_suite_integration_tests_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,32 @@ jobs:
- name: Check for opened issues
id: check-opened
run: |
resp=$(curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/Flank/flank/issues?creator=github-actions[bot]&state=open&labels=IT_Failed" | jq '.[0] | .number' -r)
resp=$(curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/issues?creator=github-actions[bot]&state=open&labels=IT_Failed" | jq '.[0] | .number' -r)
echo "::set-output name=issue-number::${resp}"
- name: Date of last run
id: last-run-date
run: |
resp=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/Flank/flank/actions/workflows/it_cron.yml/runs?per_page=2&page=1" | jq ' [.workflow_runs | .[] | select(.status != "in_progress") | select(.conclusion != "cancelled")][0] | .created_at' -r)
resp=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/workflows/it_cron.yml/runs?per_page=2&page=1" | jq ' [.workflow_runs | .[] | select(.status != "in_progress") | select(.conclusion != "cancelled")][0] | .created_at' -r)
echo "::set-output name=last-run-date::${resp}"
- name: Create failed message
if: ${{ needs.run-it-full-suite.outputs.it-status == 'failure' }}
run: |
echo "### Full suite IT run :x: FAILED :x:" >> message.txt
echo "**Timestamp:** ${{ steps.current-time.outputs.formattedTime }}" >> message.txt
echo "**Job run:** [${{ github.run_id }}](https://github.com/Flank/flank/actions/runs/${{ github.run_id }})" >> message.txt
echo "**Job run:** [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> message.txt
echo "**Build scan URL:** ${{ needs.run-it-full-suite.outputs.build-scan-url }}" >> message.txt
echo "**Commits since the last run:**" >> message.txt
list=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/Flank/flank/commits?since=${{ steps.last-run-date.outputs.last-run-date }}" | jq ' .[] | .sha' -r)
list=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/commits?since=${{ steps.last-run-date.outputs.last-run-date }}" | jq ' .[] | .sha' -r)
if [ -z "$list" ]
then
echo "No new commits" >> message.txt
else
echo "|commit SHA|PR|" >> message.txt
echo "|---|:---:|" >> message.txt
while IFS= read -r commit; do
resp=$(curl -H "Accept: application/vnd.github.groot-preview+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/Flank/flank/commits/${commit}/pulls" | jq '.[] | {html_url, title}')
resp=$(curl -H "Accept: application/vnd.github.groot-preview+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/commits/${commit}/pulls" | jq '.[] | {html_url, title}')
if [ -z "$resp" ]; then
echo "|${commit}|-|" >> message.txt
else
Expand All @@ -111,7 +111,7 @@ jobs:
run: |
echo "### Full suite IT run :white_check_mark: SUCCEEDED :white_check_mark:" >> message.txt
echo "**Timestamp:** ${{ steps.current-time.outputs.formattedTime }}" >> message.txt
echo "**Job run:** [${{ github.run_id }}](https://github.com/Flank/flank/actions/runs/${{ github.run_id }})" >> message.txt
echo "**Job run:** [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> message.txt
echo "**Build scan URL:** ${{ needs.run-it-full-suite.outputs.build-scan-url }}" >> message.txt
echo "**Closing issue**" >> message.txt
Expand Down

0 comments on commit c49b850

Please sign in to comment.