Merge pull request #108 from ror-community/v1.33 #50
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: Deploy to Staging | |
on: | |
push: | |
branches: | |
- 'staging' | |
paths-ignore: | |
- '**/README.md' | |
- '**/workflows/**' | |
env: | |
MERGE_SHA: ${{ github.event.after }} | |
REPO_INFO: ${{ github.event.repository.full_name }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} | |
jobs: | |
copy-files: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get Merge PR | |
uses: octokit/[email protected] | |
id: get_merge_pr | |
with: | |
route: GET /search/issues | |
q: 'repo:${{ github.event.repository.full_name }}+is:pr+is:closed+merge_sha_commit:${{ github.event.after }}' | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- name: Get branch name | |
run: | | |
export url=${{ fromJson(steps.get_merge_pr.outputs.data).items[0].pull_request.url }} | |
echo "release_branch=$(curl ${url} | jq -r .head.ref)" >> $GITHUB_ENV | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: Install aws cli | |
id: install-aws-cli | |
uses: unfor19/[email protected] | |
- name: Zip and copy files | |
id: copyfiles | |
run: | | |
cd ./${{ env.release_branch }} | |
zip files.zip *.json | |
aws s3 cp files.zip s3://${{ secrets.ROR_DATA_S3_BUCKET_STAGING }}/${{ env.release_branch }}/files.zip | |
aws s3 ls s3://${{ secrets.ROR_DATA_S3_BUCKET_STAGING }}/${{ env.release_branch }}/files.zip | |
- 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: 'Copy status to staging S3 Bucket: ${{ steps.copyfiles.outcome }}. On branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}' | |
- name: Index file | |
id: indexdata | |
run: | | |
cd .github/workflows | |
python -m pip install --upgrade pip | |
pip install requests==2.23.0 | |
python index_files.py -u ${{ secrets.INDEX_STAGING_API_URL }} -d ${{ env.release_branch }} -he ${{ secrets.INDEX_STAGING_API_HEADERS }} | |
- 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: 'Staging index status: ${{ steps.indexdata.outcome }}. On branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.release_branch }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}' | |