Mirror workflow #1071
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
# This is a basic workflow that is manually triggered | |
name: Mirror workflow | |
# Controls when the action will run. Workflow runs when manually triggered using the UI | |
# or API. | |
on: | |
workflow_dispatch: | |
inputs: | |
suffix: | |
description: "Suffix to be added to tag" | |
required: false | |
schedule: | |
- cron: "42 6 * * *" | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
mirror: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Runs a single command using the runners shell | |
- name: Set environment vars | |
run: | | |
echo "PULLDATE=$(date +%F)" >> $GITHUB_ENV | |
echo "FULLTIME=$(date)" >> $GITHUB_ENV | |
test -z ${{ github.event.inputs.suffix }} && echo "TAGNAME=$(date +%F)" >> $GITHUB_ENV | |
test -z ${{ github.event.inputs.suffix }} || echo "TAGNAME=$(date +%F)${{ github.event.inputs.suffix }}" >> $GITHUB_ENV | |
echo "$GITHUB_ENV" | |
test -f $GITHUB_ENV && cat $GITHUB_ENV | |
- name: Check out repository code | |
uses: actions/checkout@v2 | |
with: | |
path: bin | |
- name: Checkout last mirror | |
uses: actions/checkout@v2 | |
with: | |
ref: releases | |
path: mirror | |
- name: Mirror archive data | |
run: | | |
cp bin/mirror.repec.sh mirror/ | |
cp bin/README.md mirror/ | |
chmod +x mirror/mirror.repec.sh | |
cd mirror/ | |
./mirror.repec.sh | |
# Capture all the PKG files | |
- name: Capture PKG files | |
run: | | |
zip -rp stata-pkg-files.zip $(find mirror/fmwww.bc.edu/repec/bocode -iname \*.pkg) | |
# Upload as artifact | |
- name: Upload artifact of PKG files | |
uses: actions/upload-artifact@v4 | |
with: | |
name: stata-pkg-files | |
path: stata-pkg-files.zip | |
# Deploy to a new branch | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: mirror | |
publish_branch: releases | |
keep_files: true | |
full_commit_message: "Snapshot of SSC Archive as of ${{ env.FULLTIME }}" | |
tag_name: ${{ env.PULLDATE }}${{ github.event.inputs.suffix }} | |
tag_message: "Snapshot of SSC Archive as of ${{ env.FULLTIME }}${{ github.event.inputs.tags }}" |