Cypress runner image upload #24594
This file contains 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: Cypress runner image upload | |
on: | |
schedule: | |
- cron: "*/30 * * * *" | |
workflow_dispatch: | |
jobs: | |
changes: | |
name: Cypress runner image update | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout hac-dev | |
uses: actions/checkout@v3 | |
with: | |
repository: openshift/hac-dev | |
path: hac-dev | |
fetch-depth: 0 | |
- name: Check the changes to tests since last run | |
id: changes | |
run: | | |
cd hac-dev | |
podman pull quay.io/hacdev/hac-tests:next | |
builddate=$(podman inspect quay.io/hacdev/hac-tests:next --format "{{.Created}}" | sed -r 's/\sUTC//') | |
changedate=$(TZ=UTC git log --date=iso-local --format=%cd -n 1 --first-parent -- integration-tests/) | |
echo "last image build date: $builddate" | |
echo "last change date: $changedate" | |
buildstamp=$(date -d "$builddate" +%s) | |
changestamp=$(date -d "$changedate" +%s) | |
if [ $changestamp -lt $buildstamp ]; then | |
echo "No changes" | |
echo "push_image=false" >> $GITHUB_OUTPUT | |
else | |
echo "Changes detected" | |
echo "push_image=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Build and push image | |
if: steps.changes.outputs.push_image == 'true' | |
env: | |
USERNAME: ${{ secrets.QUAY_USER }} | |
TOKEN: ${{ secrets.QUAY_TOKEN }} | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
CHANNEL_ID: "C04U7TA1BT8" # forum-rhtap-test-execution-alerts | |
ACTION_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
run: | | |
cd hac-dev/integration-tests | |
podman build -f Dockerfile -t quay.io/hacdev/hac-tests:next | |
podman login -u="$USERNAME" -p="$TOKEN" quay.io | |
podman push quay.io/hacdev/hac-tests:next | |
# send a comment to Slack about the latest digest | |
digest=$(curl 'https://quay.io/api/v1/repository/hacdev/hac-tests/tag/?limit=1000&page=1&onlyActiveTags=true' | jq '.tags[] | select(.name=="next") | .manifest_digest') | |
digest=${digest//\"/} # remove quotes | |
digest=${digest:7:12} # shorten to 12 chars to be same as manifest short sha on a web | |
curl -H "Authorization: Bearer ${SLACK_BOT_TOKEN}" -d "text=:incoming_envelope: Job *Cypress runner image upload* pushed new *hacdev/hac-tests:next* image with digest *${digest}*. <${ACTION_URL}|View logs> | <https://quay.io/repository/hacdev/hac-tests?tab=tags|Visit quay>" -d "channel=${CHANNEL_ID}" -X POST https://slack.com/api/chat.postMessage |