Skip to content

Commit

Permalink
cicd: add some composite actions
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Nov 1, 2021
1 parent b9a9d06 commit 9bb8cc7
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/actions/documentation/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Documentation'
description: 'build with mdBook and optionally push'
inputs:
publish:
description: 'push resulting files to gh-pages'
default: 'true'
token:
description: 'github token'
default: ${{ github.token }}
runs:
using: 'composite'
steps:
- uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: 'latest'
- shell: sh
run: |
d="$(echo "${GITHUB_REF#refs/tags/}" | sed '/^refs\/heads\//d')"
if test -z "$d"; then
exec mdbook build
else
exec mdbook build --dest-dir "./book/${d}"
fi
- uses: peaceiris/actions-gh-pages@v3
# This conditional doesn't exist yet.
if: ${{ inputs.publish }}
with:
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
github_token: ${{ inputs.token }}
publish_dir: ./book
keep_files: true
47 changes: 47 additions & 0 deletions .github/actions/set-image-expiration/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Set Image Expiration'
description: 'Use the Quay API to set an expiration time on an image'
inputs:
quay:
description: 'Quay instance to issue calls to.'
required: false
default: 'quay.io'
duration:
description: 'Duration (in seconds) into the future to expire the image.'
required: false
default: 1209600
repo:
description: 'Namespace & repository'
required: true
tag:
description: 'image tag'
required: true
token:
description: 'API token'
required: true
runs:
using: 'composite'
steps:
- id: add-mask
shell: sh
run: |
printf '::add-mask::%s\n' "${{ inputs.token }}"
- id: write-script
shell: sh
run: |
jq -n -c --argjson e "$(($(date -u +%s) + ${{ inputs.duration }}))" '{expiration: $e}' > "${RUNNER_TEMP}/expiration.json"
cat <<. >"${RUNNER_TEMP}/run"
#!/usr/bin/env -S curl -K
silent
show-error
fail-with-body
data-binary="@${RUNNER_TEMP}/expiration.json"
header="Authorization: Bearer ${{ inputs.token }}"
header="Content-Type: application/json"
header="Accept: application/json"
request=PUT
url="https://${{ inputs.quay }}/api/v1/repository/${{ inputs.repo }}/tag/${{ inputs.tag }}"
.
chmod +x "${RUNNER_TEMP}/run"
- id: call
shell: sh
run: '${RUNNER_TEMP}/run'

0 comments on commit 9bb8cc7

Please sign in to comment.