Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 9 additions & 47 deletions .github/workflows/check-wcag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,50 +47,12 @@ jobs:

- name: Upload WCAG report to Slack
if: always()
env:
SLACK_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
run: |
set -e
sudo apt-get update && sudo apt-get install -y jq

FILESIZE=$(wc -c < wcag-report.txt)

echo "File size: $FILESIZE"

UPLOAD_JSON=$(curl --silent --request POST \
--url https://slack.com/api/files.getUploadURLExternal \
--header "authorization: Bearer $SLACK_TOKEN" \
--header "content-type: application/x-www-form-urlencoded; charset=utf-8" \
--data filename=wcag-report.txt \
--data length=$FILESIZE)

echo "UPLOAD_JSON: $UPLOAD_JSON"

UPLOAD_URL=$(echo "$UPLOAD_JSON" | jq -r '.upload_url')
FILE_ID=$(echo "$UPLOAD_JSON" | jq -r '.file_id')

if [ "$UPLOAD_URL" = "null" ] || [ -z "$UPLOAD_URL" ]; then
echo "Upload URL ontbreekt! Slack response: $UPLOAD_JSON"
exit 1
fi

UPLOAD_HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
-F "filename=@wcag-report.txt" \
"$UPLOAD_URL")

echo "UPLOAD HTTP STATUS: $UPLOAD_HTTP_STATUS"
sleep 5;
echo $CHANNEL_ID

COMPLETE_RESPONSE=$(curl --silent -X POST \
-H "Authorization: Bearer $SLACK_TOKEN" \
-H "Content-Type: application/json" \
--data "{\"files\":[{\"id\":\"$FILE_ID\"}],\"channel_id\":\"$CHANNEL_ID\",\"initial_comment\":\"WCAG rapport:\"}" \
https://slack.com/api/files.completeUploadExternal)

echo "COMPLETE_RESPONSE: $COMPLETE_RESPONSE"
if [ "$(echo "$COMPLETE_RESPONSE" | jq -r '.ok')" != "true" ]; then
echo "Error completing upload: $COMPLETE_RESPONSE"
exit 1
fi
uses: slackapi/slack-github-action@v2.1.1
with:
method: files.uploadV2
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel_id: ${{ secrets.SLACK_CHANNEL_ID }}
initial_comment: "WCAG rapport:"
file: "./wcag-report.txt"
filename: "wcag-report.txt"
Loading