Backup nf-core pipelines #8
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" | |
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 | |
env: | |
TARBALL_FILENAME: ${{ matrix.pipeline }}_$(date +%Y-%m-%d_%H-%M).tar.gz | |
steps: | |
- name: Clone the repository | |
run: git clone --mirror https://github.com/nf-core/${{ matrix.pipeline }}.git | |
- name: Make a tarball | |
run: tar czf $TARBALL_FILENAME ${{ matrix.pipeline }}.git | |
- 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 | |
- name: Upload repository to S3 | |
run: | | |
aws s3 cp $TARBALL_FILENAME s3express://nf-core-repos-backup--euw1-az1--x-s3/$TARBALL_FILENAME |