From bffb1c213f7dce978fe382aeed1e0429f6f8e7c1 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Wed, 3 Apr 2024 11:32:38 -0500 Subject: [PATCH] add generate dump action for 1st v2 release --- .../generate_dump_v2_initial_release.yml | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 .github/workflows/generate_dump_v2_initial_release.yml diff --git a/.github/workflows/generate_dump_v2_initial_release.yml b/.github/workflows/generate_dump_v2_initial_release.yml new file mode 100644 index 000000000..d7d85a798 --- /dev/null +++ b/.github/workflows/generate_dump_v2_initial_release.yml @@ -0,0 +1,106 @@ +name: Create data dump v2 first release +description: Generates a data dump based on an input file from ror-data-test and uploades the result to ror-data. For use during the first v1 release only. +on: + workflow_dispatch: + inputs: + schema-version: + required: true + description: Release schema version + type: choice + options: + - v1 + - v2 + new-release: + type: string + description: Name of the directory that the new release is located in + prev-release: + type: string + description: Name of the existing release zip file to base this data dump from + +jobs: + generate-dump: + runs-on: ubuntu-latest + steps: + - name: Echo message + id: echo_message + run: echo "Github action triggered with inputs new release ${{github.event.inputs.new-release}} and previous release ${{github.event.inputs.prev-release}}" + - name: checkout ror records repo + uses: actions/checkout@v2 + with: + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + path: ./ror-records-test + - name: checkout ror data test repo + uses: actions/checkout@v2 + with: + repository: ror-community/ror-data-test + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + path: ./ror-data-test + - name: checkout ror data prod repo + uses: actions/checkout@v2 + with: + repository: ror-community/ror-data + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + path: ./ror-data-prod + - name: copy previous data dump file + id: copyprevdump + run: | + cp -R ./ror-data-test/${{github.event.inputs.prev-release}}.zip ./ror-records-test + - name: checkout ror curation ops repo + uses: actions/checkout@v2 + with: + repository: ror-community/curation_ops + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + ref: v2-crosswalk + path: ./curation_ops + - name: Set up Python environment + uses: actions/setup-python@v2 + with: + python-version: "3.8" + - name: execute script + id: gendumpscript + run: | + cd ./curation_ops/generate_dump/ + if [[ ${{ github.event.inputs.schema-version }} == 'v1' ]]; then + python generate_dump.py -r ${{github.event.inputs.new-release}} -e ${{github.event.inputs.prev-release}} -i '../../ror-records-test' -o '../../ror-records-prod' -v 1 + fi + if [[ ${{ github.event.inputs.schema-version }} == 'v2' ]]; then + python generate_dump.py -r ${{github.event.inputs.new-release}} -e ${{github.event.inputs.prev-release}} -i '../../ror-records-test' -o '../../ror-records-prod' -v 2 + fi + - name: cat error file + if: ${{ steps.gendumpscript.outcome != 'success'}} + run: | + echo "ERRORS found:" + cat errors.log + - name: copy new data dump file + id: copynewdump + run: | + yes | cp -rf ./ror-records-prod/${{github.event.inputs.new-release}}*.zip ./ror-data-prod + - name: commit dump file + id: commitdumpfile + if: ${{ steps.copynewdump.outcome == 'success'}} + run: | + cd ./ror-data-prod + git config --local user.email "ror-bot@ror.org" + git config --local user.name "ror-bot" + git add *.zip + git commit -m "add new data dump file" + git push origin main + - name: commit changed files + if: ${{ steps.commitdumpfile.outcome == 'success'}} + run: | + pwd + cd ./ror-records-test + git config --local user.email "ror-bot@ror.org" + git config --local user.name "ror-bot" + git add ${{github.event.inputs.new-release}}/v1/ + git commit -m "add generated v1 files" + git push origin main + - name: Notify Slack + if: always() + uses: edge/simple-slack-notify@master + env: + SLACK_WEBHOOK_URL: ${{ secrets.CURATOR_SLACK_WEBHOOK_URL }} + with: + channel: '#ror-curation-releases' + color: 'good' + text: 'DEV Data dump ${{github.event.inputs.new-release}} generation status: ${{ steps.commitdumpfile.outcome }}. Using base version ${{ github.event.inputs.schema-version }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}'