Backup nf-core pipelines #11
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: Backup nf-core pipelines | |
on: | |
# schedule: | |
# Runs at 00:00 UTC every Sunday | |
# - cron: '0 0 * * 0' # TODO: Uncomment this after testing | |
workflow_dispatch: | |
inputs: | |
pipeline: | |
description: "Pipeline to backup" | |
required: true | |
default: "all" | |
# Add permissions block here | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
get-pipelines: | |
runs-on: "ubuntu-latest" | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- id: set-matrix | |
run: | | |
json=$(curl -s https://nf-co.re/pipeline_names.json) | |
# Default to "all" if running on schedule (no inputs available) or if input is "all" | |
if [ -z "${{ inputs.pipeline }}" ] || [ "${{ inputs.pipeline }}" = "all" ]; then | |
echo "matrix=$(echo $json | jq -c '.')" >> $GITHUB_OUTPUT | |
else | |
echo "matrix=$(echo $json | jq -c --arg p "${{ inputs.pipeline }}" '{pipeline: [.pipeline[] | select(. == $p)]}')" >> $GITHUB_OUTPUT | |
fi | |
backup: | |
needs: get-pipelines | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: ${{fromJson(needs.get-pipelines.outputs.matrix)}} | |
fail-fast: false | |
steps: | |
- name: Clone the nf-core/${{ matrix.pipeline }} repository | |
run: git clone --mirror https://github.com/nf-core/${{ matrix.pipeline }}.git | |
- name: Make a tarball | |
id: make-tarball | |
run: | | |
TARBALL_FILENAME="${{ matrix.pipeline }}_$(date +%Y-%m-%d_%H-%M).tar.gz" | |
tar czf $TARBALL_FILENAME ${{ matrix.pipeline }}.git | |
echo "TARBALL_FILENAME=$TARBALL_FILENAME" >> $GITHUB_OUTPUT | |
- name: setup aws cli | |
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1 | |
with: | |
role-to-assume: ${{ secrets.AWS_BACKUP_ROLE }} | |
aws-region: eu-west-1 | |
role-session-name: GithubActionsBackup | |
audience: sts.amazonaws.com | |
- name: Upload repository to S3 | |
run: | | |
aws s3 cp "${{ steps.make-tarball.outputs.TARBALL_FILENAME }}" "s3express://nf-core-repos-backup--euw1-az1--x-s3/${{ steps.make-tarball.outputs.TARBALL_FILENAME }}" | |