Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Publish NPM package (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi committed Mar 20, 2024
1 parent fdbd674 commit b2ffdba
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 11 deletions.
22 changes: 19 additions & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
**What happened**:
Changelog
---------

**What you expected to happen**:
### Added

**How to reproduce it**:
### Changed

### Deprecated

### Removed

### Fixed

### Security

Checklist
---------

- [ ] Test
- [ ] Self-review
- [ ] Documentation
60 changes: 54 additions & 6 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ name: Screwdriver API CI/CD
branches:
- master

env:
USER: QubitPi
EMAIL: jack20220723@gmail.com

jobs:
tests:
name: Tests
Expand All @@ -20,9 +24,8 @@ jobs:
- run: npm install
- run: npm test

docker-image:
name: Build Test & Release Docker Image
needs: tests
docker-test:
name: Test Docker Image Build
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -36,21 +39,66 @@ jobs:
with:
context: .
push: false

release:
name: Publish NPM Packages
if: github.ref == 'refs/heads/master'
needs: [tests, docker-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # this is needed for feching tags for "tag-for-release.bash" below
- name: Set node version to 18
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Download auto-version bump scripts
run: |
git clone https://github.com/QubitPi/hashicorp-aws.git ../hashicorp-aws
cp ../hashicorp-aws/auxiliary/github/tag-for-release.bash .github/
cp ../hashicorp-aws/auxiliary/github/upversion.py .github/
- name: Tag for release
run: |
git config --global user.name '$USER'
git config --global user.email '$EMAIL'
.github/tag-for-release.bash
- name: Set release version
run: |
VERSION=$(git describe)
npm version $VERSION
- name: Publish to NPM Packages
run: |
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

docker-image:
name: Release Docker Image
if: github.ref == 'refs/heads/master'
needs: [tests, docker-test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push image to DockerHub
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/screwdriver:latest
- name: Docker Hub Description
if: github.ref == 'refs/heads/master'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN npm install -g npm
RUN npm cache clean -f

# Install Screwdriver API
RUN npm install --fetch-timeout=1200000 screwdriver-api@$VERSION
RUN npm install screwdriver-cd-api@$VERSION
WORKDIR /usr/src/app/node_modules/screwdriver-api

# Setup configuration folder
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "screwdriver-api",
"name": "screwdriver-cd-api",
"version": "7.0.0",
"description": "API server for the Screwdriver.cd service",
"main": "index.js",
Expand Down

0 comments on commit b2ffdba

Please sign in to comment.