test: rename workflow names and their files #1
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 preview for PR develop | ||
on: | ||
workflow_run: | ||
workflows: [Build preview for PR develop] | ||
types: | ||
- completed | ||
branches: | ||
- develop | ||
permissions: | ||
contents: read | ||
id-token: write | ||
pull-requests: write | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }} | ||
cancel-in-progress: false | ||
env: | ||
HUGO_BASEURL: "https://preview-developer.espressif.com/pr${{ github.event.workflow_run.pull_requests[0].number }}/" | ||
jobs: | ||
deploy-preview: | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- name: Debug: List workflow details | ||
run: | | ||
echo "Workflow name: ${{ github.event.workflow_run.name }}" | ||
echo "Pull request: ${{ github.event.workflow_run.pull_requests[0].number }}" | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: public-folder | ||
path: ./public | ||
- name: Deploy to AWS S3 PR-specific subdirectory | ||
uses: jakejarvis/s3-sync-action@master | ||
with: | ||
args: --follow-symlinks --delete --cache-control no-cache | ||
env: | ||
AWS_S3_BUCKET: ${{ secrets.PREVIEW_AWS_BUCKET_NAME }} | ||
SOURCE_DIR: './public' | ||
DEST_DIR: "pr${{ github.event.workflow_run.pull_requests[0].number }}" | ||
AWS_REGION: ${{ secrets.AWS_REGION }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
- name: Post Preview Link to PR | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.event.workflow_run.pull_requests[0].number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: `🎉 A preview of this PR is available at: ${{ env.HUGO_BASEURL }}` | ||
}) | ||
- name: Invalidate CloudFront cache for PR | ||
uses: chetan/invalidate-cloudfront-action@v2 | ||
env: | ||
PATHS: "/pr-${{ github.event.workflow_run.pull_requests[0].number }}/*" | ||
DISTRIBUTION: ${{ secrets.PREVIEW_CLOUDFRONT_DISTRIBUTION }} | ||
AWS_REGION: ${{ secrets.AWS_REGION }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |