forked from IITC-CE/ingress-intel-total-conversion
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing the PR build from the site after a PR merge
- Loading branch information
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: After PR merging | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
if_merged: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/checkout@v3 | ||
env: | ||
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }} | ||
if: ${{ env.WEBSITE_REPO != '' }} | ||
with: | ||
repository: ${{ secrets.WEBSITE_REPO }} | ||
ref: 'master' | ||
token: ${{ secrets.API_TOKEN_GITHUB }} | ||
|
||
- name: Setup git config | ||
env: | ||
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }} | ||
if: ${{ env.WEBSITE_REPO != '' }} | ||
run: | | ||
git config user.name "userz" | ||
git config user.email "<>" | ||
- name: Delete old build artifacts | ||
env: | ||
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }} | ||
if: ${{ env.WEBSITE_REPO != '' }} | ||
run: | | ||
git rm -r static/build/artifact/PR${{ github.event.number }}/ | ||
git commit -m "🤖 PR №${{ github.event.number }} merged, deleting old build artifacts" | ||
- run: git push origin master | ||
env: | ||
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }} | ||
if: ${{ env.WEBSITE_REPO != '' }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ jobs: | |
steps: | ||
- name: 'Download artifact' | ||
uses: actions/github-script@v6 | ||
env: | ||
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }} | ||
if: ${{ env.WEBSITE_REPO != '' }} | ||
with: | ||
script: | | ||
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
|
@@ -37,9 +40,15 @@ jobs: | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/build.zip`, Buffer.from(download.data)); | ||
- name: 'Unzip artifact' | ||
env: | ||
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }} | ||
if: ${{ env.WEBSITE_REPO != '' }} | ||
run: unzip build.zip | ||
|
||
- name: Set env | ||
env: | ||
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }} | ||
if: ${{ env.WEBSITE_REPO != '' }} | ||
run: | | ||
echo "PR_NUMBER=$(cat ./.metadata/number)" >> "$GITHUB_ENV" | ||
echo "COMMIT_HASH=$(cat ./.metadata/commit)" >> "$GITHUB_ENV" | ||
|
@@ -60,12 +69,12 @@ jobs: | |
destination_folder: 'static/build/artifact/PR${{ env.PR_NUMBER }}/' | ||
user_email: '[email protected]' | ||
user_name: 'IITC Updates' | ||
commit_message: '🤖 New IITC test build from https://github.com/${{ github.repository }}/commit/${{ github.sha }}' | ||
commit_message: '🤖 New build PR №{{ env.PR_NUMBER }} from https://github.com/${{ github.repository }}/commit/${{ github.sha }}' | ||
|
||
- name: Comment with build url | ||
if: ${{ env.WEBSITE_REPO != '' }} | ||
env: | ||
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }} | ||
if: ${{ env.WEBSITE_REPO != '' }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: pr_release | ||
|