Skip to content

Commit

Permalink
trying docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeshsusai committed Oct 15, 2024
1 parent 31145b9 commit 71548da
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 29 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI test

on: [push]
Expand All @@ -16,11 +13,11 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm test
114 changes: 93 additions & 21 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,107 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package
name: NPM Pipeline

on:
workflow_call: {}
push:
branches:
- "*"
tags:
- 'v*'
- "v*"

jobs:
build:
Test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: "npm"
registry-url: https://registry.npmjs.org
cache-dependency-path: package-lock.json
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_INSTALL_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

Build:
runs-on: ubuntu-latest
needs: Test

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test
node-version-file: '.nvmrc'
cache: "npm"
registry-url: https://registry.npmjs.org
cache-dependency-path: package-lock.json
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_INSTALL_TOKEN }}

- name: Install dependencies
run: npm ci

publish-npm:
needs: build
Publish:
runs-on: ubuntu-latest
needs: Build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish
node-version-file: '.nvmrc'
cache: "npm"
registry-url: https://registry.npmjs.org
cache-dependency-path: package-lock.json
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Publish package
run: npm publish

- name: Build package
run: npm run build-packages

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: awsudo/awsudo:${{github.ref_name}}

Deploy Docker Image:
runs-on: ubuntu-latest
needs: Publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: awsudo/awsudo:${{github.ref_name}}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: scripts/deploy-docker
3 changes: 1 addition & 2 deletions scripts/deploy-docker
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ done
printf "\n%s available!\n\n" "$VERSION"

echo "Deploying: awsudo/awsudo"
docker login

LATEST_NODE_LTS=iron

echo "Publishing tags specific to node LTS releases..."
for NODE_LTS in "fermium" "gallium" "hydrogen" "iron"; do
for NODE_LTS in "gallium" "hydrogen" "iron"; do
docker build --build-arg node_lts="$NODE_LTS" --build-arg version="$VERSION" . \
-t awsudo/awsudo:"$NODE_LTS" \
-t awsudo/awsudo:v"${VERSION}"-"$NODE_LTS"
Expand Down

0 comments on commit 71548da

Please sign in to comment.