Skip to content

Deploy post for review #666

Deploy post for review

Deploy post for review #666

name: Deploy post for review
on:
workflow_run:
workflows: ["filter-files"]
types:
- completed
jobs:
upload:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Download build artifact from triggered workflow
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ github.event.workflow_run.id }}
# name: website_out
# path: site_out
search_artifacts: true
- run: unzip website_out/site.zip
# set the SLUG environment variable to the contests of website_out/slug.txt
- name: Get SLUG
run: echo "SLUG=$(cat website_out/slug.txt)" >> $GITHUB_ENV
- name: Print SLUG
run: echo ${{env.SLUG}}
# the post name is the slug minus the first 11 characters
- name: Get post name
run: echo "POST_NAME=${SLUG:11}" >> $GITHUB_ENV
- name: Print POST_NAME
run: echo ${{env.POST_NAME}}
- name: Get ISSUE_NUMBER
run: echo "ISSUE_NUMBER=$(cat website_out/pr_number.txt)" >> $GITHUB_ENV
- name: Print ISSUE_NUMBER
run: echo ${{env.ISSUE_NUMBER}}
- name: Setup AWS CLI
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- run: aws s3 sync --region eu-west-1 --acl public-read _site s3://iclr-blogposts-2024/${{env.SLUG}}-${{env.ISSUE_NUMBER}}
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: ${{ env.ISSUE_NUMBER }},
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Thanks for your submission! We have successfully built your website and we will push it shortly to the URL https://d2jud02ci9yv69.cloudfront.net/${{env.SLUG}}-${{env.ISSUE_NUMBER}}/blog/${{env.POST_NAME}}/ !'
})