Skip to content

Commit

Permalink
create composite actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Joli Lui committed Jul 13, 2023
1 parent 70e7bcc commit dea691c
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 74 deletions.
36 changes: 36 additions & 0 deletions .github/actions/release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: GitHub release and Publish to NPM
description: Create a GitHub release and publish to NPM

inputs:
github-token:
required: true
description: 'The GitHub token to use for authentication'
release-tag:
required: true
description: 'The tag to use for the release'

runs:
using: 'composite'
steps:
# - name: Create GitHub Release
# uses: DevCycleHQ/release-action/gh-release@main
# with:
# draft: true
# prerelease: true
# github-token: ${{ inputs.github-token }}

# Replace with DevCycleHQ/release-action/gh-release@main when it's ready
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
name: "${{ inputs.release-tag }}"
tag: "${{ inputs.release-tag }}"
generateReleaseNotes: "true"
makeLatest: "true"
token: ${{ inputs.github-token }}

- name: Publish to NPM
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}
run: npm publish --access public
49 changes: 49 additions & 0 deletions .github/actions/update-doc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Update Doc

description: 'Update the CLI version in devcycle-docs'

inputs:
latest_tag:
required: true
description: 'The latest tag from the workflow that uses this action'
access_token:
required: true
description: 'The access token to use for authentication'

runs:
using: 'composite'
steps:
- name: Check out code
uses: actions/checkout@v3
with:
repository: DevCycleHQ/devcycle-docs
path: devcycle-docs
# need to get/update access token
token: ${{ inputs.access_token }}
fetch-depth: 0

- name: Set branch name
shell: bash
working-directory: devcycle-docs
run: echo "BRANCH_NAME=update-cli-version-to-${{ inputs.latest_tag }}" >> $GITHUB_ENV

- name: Update CLI version in docs repo
shell: bash
working-directory: devcycle-docs
run: |
git checkout -b "$BRANCH_NAME"
sed -i "s/const DVC_CLI_VERSION = .*/const DVC_CLI_VERSION = '${{ inputs.latest_tag }}' \/\/ auto updated by dvc cli release workflow/" docusaurus.config.js
git add docusaurus.config.js
git commit -m "Update CLI version to ${{ inputs.latest_tag }}"
- name: Push code to docs repo
shell: bash
working-directory: devcycle-docs
run: git push --set-upstream origin "$BRANCH_NAME"

- name: Create PR
shell: bash
working-directory: devcycle-docs
env:
GH_TOKEN: ${{ inputs.access_token }}
run: gh pr create --repo DevCycleHQ/devcycle-docs --base main --head "$BRANCH_NAME" --title "Update CLI version to $LATEST_TAG" --body "This PR was automatically created by the DevCycle CLI release workflow."
19 changes: 16 additions & 3 deletions .github/workflows/tag.yml → .github/workflows/cli-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tag New Version
name: CLI Release

on:
workflow_dispatch:
Expand All @@ -8,7 +8,7 @@ permissions:
contents: write

jobs:
tag-new-version:
cli-release:
runs-on: ubuntu-latest
steps:
- name: Check out code
Expand Down Expand Up @@ -43,4 +43,17 @@ jobs:
git add .
git commit --amend -m "Release $LATEST_TAG"
git tag -f $LATEST_TAG
git push origin main --follow-tags
git push --atomic origin main $LATEST_TAG
- name: Release
uses: ./.github/actions/release
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: $LATEST_TAG

- name: Update Doc
uses: ./.github/actions/update-doc
with:
latest_tag: $LATEST_TAG
# need to get/update access token
access_token: ${{ secrets.PAT_TOKEN }}
22 changes: 0 additions & 22 deletions .github/workflows/release.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/update_doc.yml

This file was deleted.

0 comments on commit dea691c

Please sign in to comment.