Skip to content

Commit

Permalink
improve action
Browse files Browse the repository at this point in the history
  • Loading branch information
rutesantos4 committed Sep 24, 2023
1 parent 3f2b614 commit d8a4715
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions .github/workflows/publish-github.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
jobs:
publish:
runs-on: ubuntu-latest

env:
release-asset-name: dist.zip

steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -21,16 +25,16 @@ jobs:
- name: Install npm
run: npm install --frozen-lockfile

# - name: Create Release Pull Request or Publish
# id: changesets
# uses: changesets/action@v1
# with:
# publish: bash scripts/release.sh
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
publish: bash scripts/release.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build project
# if: steps.changesets.outputs.published == 'true'
if: steps.changesets.outputs.published == 'true'
id: build-project
run: npm run build

Expand All @@ -40,14 +44,7 @@ jobs:
uses: vimtor/action-zip@v1
with:
files: dist
dest: dist.zip

- name: store Zip dist folder
if: steps.zip-folder.outcome == 'success'
uses: actions/upload-artifact@v1
with:
name: dist-action
path: ${{ github.workspace }}/dist.zip
dest: ${{ env.release-asset-name }}

- name: Upload Release Asset
if: steps.zip-folder.outcome == 'success'
Expand All @@ -56,7 +53,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
async function getReleaseId() {
try {
const response = await github.rest.repos.getLatestRelease({
Expand All @@ -79,8 +76,8 @@ jobs:
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
release_id: release_id,
name: 'dist.zip',
data: await fs.readFileSync('${{ github.workspace }}/dist.zip')
name: '${{ env.release-asset-name }}',
data: await fs.readFileSync('${{ github.workspace }}/${{ env.release-asset-name }}')
});
console.log(`Uploaded asset to release ${release_id}.`);
Expand Down

0 comments on commit d8a4715

Please sign in to comment.