Make sure there is no old data on curl retries #491
Workflow file for this run
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
# Copyright (C) 2022 ScyllaDB | |
name: Images | |
on: | |
push: | |
# Restrict the branches to only those we want to promote from. | |
branches: | |
- 'master' | |
pull_request: | |
branches: | |
- '**' | |
types: | |
- opened | |
- edited | |
- reopened | |
- synchronize | |
schedule: | |
- cron: '0 9 * * *' # daily at 9am | |
workflow_dispatch: {} | |
env: | |
image_registry: quay.io | |
image_repo_ref: quay.io/${{ github.repository }} | |
retention_days: 90 | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
path: ${{ env.git_repo_path }} | |
- name: Build | |
run: | | |
make build REPO=${{ env.image_repo_ref }} --warn-undefined-variables | |
- name: Save images | |
run: | | |
mkdir ~/images/ | |
for image_ref in $( cat .build_state ); do | |
image_name="$( echo "${image_ref}" | sed -E -e 's/.*:(.*)/\1/' )" | |
podman save "${image_ref}" | lz4 - ~/images/"${image_name}".tar.lz4 | |
done | |
- name: Upload image names | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build_state | |
path: ./.build_state | |
if-no-files-found: error | |
retention-days: ${{ env.retention_days }} | |
- name: Upload image artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: images | |
path: ~/images/*.tar.lz4 | |
if-no-files-found: error | |
retention-days: ${{ env.retention_days }} | |
promote: | |
name: Promote images | |
runs-on: ubuntu-22.04 | |
needs: | |
- build | |
if: ${{ github.event_name != 'pull_request' }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
path: ${{ env.git_repo_path }} | |
- uses: actions/download-artifact@v2 | |
with: | |
name: build_state | |
path: ./ | |
- uses: actions/download-artifact@v2 | |
with: | |
name: images | |
path: ~/images/ | |
- name: Load image | |
run: | | |
for f in ~/images/*.tar.lz4; do | |
unlz4 "${f}" --to-stdout | podman load | |
done | |
- name: Login to Image Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.image_repo_ref }} | |
username: ${{ secrets.IMAGE_REPO_USER }} | |
password: ${{ secrets.IMAGE_REPO_TOKEN }} | |
- name: Promote images | |
run: | | |
make publish-last-build REPO=${{ env.image_repo_ref }} --warn-undefined-variables | |
failure-notifications: | |
name: Failure notifications | |
runs-on: ubuntu-22.04 | |
needs: | |
- build | |
- promote | |
if: ${{ failure() && github.event_name != 'pull_request' }} | |
steps: | |
- name: Report failures to Slack | |
if: ${{ always() }} | |
working-directory: . | |
run: | | |
# We have to avoid printing the secret to logs. | |
set +x | |
curl -X POST -H 'Content-type: application/json' --data @<( cat <<-EOF | |
{ | |
"text": ":warning: CI workflow \"${{ github.workflow }}\" triggered on \"${{ github.event_name }}\" event from ${{ github.ref }} (${{ github.sha }}) failed!\n:fire_extinguisher: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} for details.:fire:" | |
} | |
EOF | |
) '${{ secrets.SLACK_WEBHOOK_URL }}' |