-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Extract branch publishing into separate workflow
- Loading branch information
1 parent
c8ac989
commit 0d90f0c
Showing
5 changed files
with
102 additions
and
112 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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,29 @@ | ||
name: CD | ||
on: | ||
workflow_run: | ||
workflows: | ||
- CI | ||
types: | ||
- completed | ||
branches: | ||
- main | ||
jobs: | ||
deploy-to-npm-branch: | ||
name: Deploy to `npm` branch | ||
if: github.event.workflow_run.event == 'push' | ||
uses: ./.github/workflows/deploy-artifact-as-branch.yml | ||
with: | ||
workflow_id: ${{github.event.workflow_run.id}} | ||
artifact_name: npmDist | ||
target_branch: npm | ||
commit_message: "Deploy ${{github.event.workflow_run.head_sha}} to 'npm' branch" | ||
|
||
deploy-to-deno-branch: | ||
name: Deploy to `deno` branch | ||
if: github.event.workflow_run.event == 'push' | ||
uses: ./.github/workflows/deploy-artifact-as-branch.yml | ||
with: | ||
workflow_id: ${{github.event.workflow_run.id}} | ||
artifact_name: denoDist | ||
target_branch: deno | ||
commit_message: "Deploy ${{github.event.workflow_run.head_sha}} to 'deno' branch" |
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
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,51 @@ | ||
name: Deploy specified artifact as a branch | ||
on: | ||
workflow_call: | ||
inputs: | ||
workflow_id: | ||
required: true | ||
type: string | ||
artifact_name: | ||
required: true | ||
type: string | ||
target_branch: | ||
required: true | ||
type: string | ||
commit_message: | ||
required: true | ||
type: string | ||
jobs: | ||
deploy-artifact-as-branch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout `${{ inputs.target_branch }}` branch | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ inputs.target_branch }} | ||
|
||
- name: Remove existing files first | ||
run: git rm -r . | ||
|
||
- name: Download artifact into cloned branch | ||
run: gh run download "$WORKFLOW_ID" -n "$ARTIFACT_NAME" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
WORKFLOW_ID: ${{ inputs.workflow_id }} | ||
ARTIFACT_NAME: ${{ inputs.artifact_name }} | ||
|
||
- name: Publish target branch | ||
run: | | ||
git add -A | ||
if git diff --staged --quiet; then | ||
echo 'Nothing to publish' | ||
else | ||
git config user.name 'GitHub Action Script' | ||
git config user.email '[email protected]' | ||
git commit -a -m "$COMMIT_MESSAGE" | ||
git push | ||
echo 'Pushed' | ||
fi | ||
env: | ||
TARGET_BRANCH: ${{ inputs.target_branch }} | ||
COMMIT_MESSAGE: ${{ inputs.commit_message }} |