Skip to content

Commit

Permalink
feat: update workflows with artifacts, remove netlify files
Browse files Browse the repository at this point in the history
  • Loading branch information
devindford committed Oct 30, 2023
1 parent df636b9 commit 38d47af
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 143 deletions.
41 changes: 37 additions & 4 deletions .github/workflows/create_preview_sites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,47 @@ jobs:
exit 1
fi
# Get the artifacts with the PR number and branch name
- name: Download artifact
uses: actions/github-script@v3.1.0
with:
script: |
const fs = require('fs');
const artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0];
const download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
fs.writeFileSync('${{ github.workspace }}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip -d pr

# Add preview link to comment if all 3 sites successfully start
- name: Comment Preview Link
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
URLIZED_BRANCH=$(echo "${{ github.head_ref }}" | tr './' '--')
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
COMMENT_CONTENT="Your preview site for the **$APP_NAME** will be ready in a few minutes, please allow time for it to build. \n \n Here's your link: \n [$APP_NAME preview](https://$URLIZED_BRANCH.$APP_ID.amplifyapp.com)"
uses: actions/github-script@v3
with:
script: |
const prInfo = fs.readFileSync('./pr/PR_INFO', 'utf8');
const prInfoLines = prInfo.split('\n');
const issueNumber = parseInt(prInfoLines[0].split(': ')[1]);
const branchName = prInfoLines[1].split(': ')[1];
const SANITIZED_BRANCH_NAME = branchName.replace(/[\/\.]/g, '-')
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: `Your preview site for the **${APP_NAME}** will be ready in a few minutes, please allow time for it to build. \n \n Heres your preview link: \n [${APP_NAME} preview](https://${SANITIZED_BRANCH_NAME}.${APP_ID}.amplifyapp.com)`
});
15 changes: 13 additions & 2 deletions .github/workflows/preview_site_trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ jobs:
approval_check:
runs-on: ubuntu-latest
steps:
- name: Check for approval
- name: Echo approval
run: |
echo "Workflow has been allowed to run for PR ${{ github.event.number }}"
echo "Workflow has been allowed to run for PR ${{ github.event.number }}. Setting artifacts and then continuing workflow runs"
- name: Save PR number and Branch name
run: |
mkdir -p ./pr
echo "PR Number: ${{ github.event.number }}" > ./pr/PR_INFO
echo "Branch Name: ${{ github.head_ref }}" >> ./pr/PR_INFO
- name: Upload PR information artifact
uses: actions/upload-artifact@v2
with:
name: pr
path: pr/
17 changes: 0 additions & 17 deletions lib/vector-vrl/web-playground/netlify.toml

This file was deleted.

109 changes: 0 additions & 109 deletions netlify.toml

This file was deleted.

9 changes: 0 additions & 9 deletions rust-doc/netlify.toml

This file was deleted.

2 changes: 0 additions & 2 deletions website/Brewfile.netlify

This file was deleted.

0 comments on commit 38d47af

Please sign in to comment.