Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #51 from 18F/45-automate-deploys
Browse files Browse the repository at this point in the history
Run on release creation rather than a magic branch
  • Loading branch information
mgwalker authored Apr 21, 2023
2 parents ab05bfb + f6b410c commit 663f83c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
34 changes: 3 additions & 31 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,27 @@
name: publish release

on:
push:
branches:
- releases
release:
types: [published]

permissions:
id-token: write

jobs:
tests:
uses: ./.github/workflows/tests.yml
publish:
name: publish release
needs: [tests]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-uri: https://registry.npmjs.org
- name: update to latest npm
run: npm i -g npm
- name: get new version
id: version
uses: actions/github-script@v6
with:
script: |
const fs = require("fs/promises");
const pkg = JSON.parse(await fs.readFile("./package.json", { encoding: "utf-8" }));
core.setOutput("version", pkg.version);
- name: install dependencies
run: npm ci
- name: publish
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: create release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
name: v${{ steps.version.outputs.version }}
tag_name: v${{ steps.versions.outputs.version }}
- name: remind author to update the release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Version ${{ steps.versions.outputs.version }} has been published to npm and a GitHub release has been created. Don't forget to update the release notes!"
})
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: tests

on: [pull_request, push, workflow_call]
on: [pull_request, push]

jobs:
test:
Expand Down

0 comments on commit 663f83c

Please sign in to comment.