diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..733126d --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,28 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Build and Test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: '18.x' + cache: 'npm' + - name: Install Dependencies + run: npm ci + - name: Build Package + run: npm run build + - name: Run Tests + run: npm run test:ci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..da95ee3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +# taken from the semantic-release documentation +# https://semantic-release.gitbook.io/semantic-release/recipes/ci-configurations/github-actions + +name: Release +on: + push: + branches: + - master + workflow_dispatch: + +permissions: + contents: read # for checkout + +jobs: + release: + name: Release + runs-on: ubuntu-latest + permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "18.x" + - name: Install dependencies + run: npm clean-install + - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies + run: npm audit signatures + - name: Build Package + run: npm run build + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm run release diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index ed78963..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,47 +0,0 @@ -pipeline { - agent { - docker { - image 'ghcr.io/department-of-veterans-affairs/health-apis-docker-octopus/lighthouse-node-application-base:node16' - registryUrl 'https://ghcr.io' - registryCredentialsId 'GITHUB_USERNAME_TOKEN' - } - } - environment { - NPM_TOKEN = credentials('LIGHTHOUSE_NPM_REGISTRY_TOKEN') - } - - stages { - stage('Setup') { - steps { - sh 'npm install' - } - } - stage('Lint') { - steps{ - sh 'npm run lint' - } - } - stage('Test') { - steps { - sh 'npm run test:ci' - } - } - stage('Build') { - steps { - sh 'npm run build' - } - } - stage('Release') { - steps { - withCredentials([ - usernamePassword( - credentialsId: 'GITHUB_USERNAME_TOKEN', - usernameVariable: 'GITHUB_USERNAME', - passwordVariable: 'GITHUB_TOKEN') - ]) { - sh 'npm run release' - } - } - } - } -}