Skip to content

Commit

Permalink
Staging for Docker and NPM (#3843)
Browse files Browse the repository at this point in the history
* chore(stg): update staging visualization workflow for Docker and npm publishing #3833

* feat(stg): add staging deployment workflow for analysis with Docker and npm publishing

* refactor(stg): remove sample file creation and GitHub Pages deployment steps from workflow

* fix(stg): add workflow_dispatch trigger to staging analysis and remove npm package step
  • Loading branch information
IhsenBouallegue authored Dec 6, 2024
1 parent 9920af9 commit b72f0b2
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 8 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/staging-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Staging Deployment - Analysis

on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'analysis/**'

jobs:
build_and_deploy:
name: Build and Deploy
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

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

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

# Get short SHA for tagging
- name: Set short SHA
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build analysis
working-directory: ./analysis
run: |
chmod +x ./gradlew
./gradlew build
# Docker build and push with staging tags
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./analysis
push: true
tags: |
codecharta/codecharta-analysis:staging
codecharta/codecharta-analysis:staging-${{ env.SHORT_SHA }}
# Publish node-wrapper to npm with staging tag
- name: Update package version
working-directory: ./analysis/node-wrapper
run: |
npm version "0.0.0-staging-${SHORT_SHA}" --no-git-tag-version
- name: Publish to npm
working-directory: ./analysis/node-wrapper
run: |
npm publish --tag staging
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

52 changes: 44 additions & 8 deletions .github/workflows/staging-visualization.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
name: Staging Environment - Visualization
name: Staging Deployment - Visualization

on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'visualization/**'

jobs:
build_and_deploy_visualization:
name: Build and Deploy Visualization

build_and_deploy:
name: Build and Deploy
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

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

- name: Setup Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Build visualization
env:
Expand All @@ -31,11 +33,45 @@ jobs:
npm ci
npm run build
- name: Deploy Visualization to GitHub Pages
# Get short SHA for tagging
- name: Set short SHA
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

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

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./visualization
push: true
tags: |
codecharta/codecharta-visualization:staging
codecharta/codecharta-visualization:staging-${{ env.SHORT_SHA }}
# Publish to npm with staging tag
- name: Update package version
working-directory: ./visualization
run: |
npm version "0.0.0-staging-${SHORT_SHA}" --no-git-tag-version
- name: Publish to npm
working-directory: ./visualization
run: |
npm publish --tag staging
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Deploy to GitHub Pages staging environment
- name: Deploy to GitHub Pages
uses: JamesIves/[email protected]
with:
token: ${{ secrets.DEPLOY_TOKEN }}
branch: gh-pages
folder: visualization/dist/webpack
target-folder: stg/visualization
clean: false
clean: true

0 comments on commit b72f0b2

Please sign in to comment.