-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from valtech-commerce/feature/implement-gha-pub…
…lish-npmjs Feature/implement gha publish npmjs
- Loading branch information
Showing
4 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Adobe - GitHub Actions - Continuous Deployment (CD) - Deploy packages to npmjs | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
call_workflow_setup: | ||
name: Setup environment | ||
uses: ./.github/workflows/reusable-workflow-setup.yml | ||
with: | ||
branch-ref: ${{ github.head_ref }} | ||
secrets: | ||
auth-token: ${{ secrets.CA_MTLA_VALTECH_ADOBE_PRACTICE_NPMJS_TOKEN }} | ||
call_workflow_build: | ||
name: Build project | ||
needs: [ call_workflow_setup ] | ||
uses: ./.github/workflows/reusable-workflow-build.yml | ||
call_workflow_publish: | ||
name: Publish packages | ||
needs: [ call_workflow_build ] | ||
uses: ./.github/workflows/reusable-workflow-publish.yml | ||
secrets: | ||
auth-token: ${{ secrets.CA_MTLA_VALTECH_ADOBE_PRACTICE_NPMJS_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Adobe reusable workflows - Build to npmjs | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
name: Build project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch checkout-repository-cache | ||
uses: actions/cache@v3 | ||
id: checkout-repository-cache | ||
with: | ||
path: ./* | ||
key: checkout-repository-cache-${{ github.sha }} | ||
|
||
# If we need to have some build process, put here | ||
# - name: Build project via 'ci:build' npm script | ||
# shell: bash | ||
# run: npm run ci:build | ||
|
||
- name: Create build-cache | ||
uses: actions/cache@v3 | ||
id: build-cache | ||
with: | ||
path: | | ||
./* | ||
!./node_modules | ||
key: build-cache-${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Adobe reusable workflows - Publish to npmjs | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
auth-token: | ||
required: true | ||
|
||
jobs: | ||
publish: | ||
name: Publish packages | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Fetch build-cache | ||
uses: actions/cache@v3 | ||
id: build-cache | ||
with: | ||
path: | | ||
./* | ||
!./node_modules | ||
key: build-cache-${{ github.sha }} | ||
|
||
- name: Publish to registry | ||
shell: bash | ||
run: | | ||
OPTS=(); | ||
if [[ $(npm pkg get version) == *"-"* ]]; then OPTS+=('--tag=next') ; fi | ||
if [[ $(npm pkg get workspaces) != "{}" ]]; then OPTS+=('--workspaces') ; fi | ||
npm publish $OPTS --access=public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.auth-token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Adobe reusable workflows - Setup to npmjs | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch-ref: | ||
required: true | ||
type: string | ||
node-version: | ||
required: false | ||
type: string | ||
default: 16 | ||
os: | ||
required: false | ||
type: string | ||
default: ubuntu-latest | ||
jfrog-artifactory: | ||
required: false | ||
type: boolean | ||
default: false | ||
secrets: | ||
github-token: | ||
required: false | ||
scope: | ||
required: false | ||
registry-url: | ||
required: false | ||
auth-token: | ||
required: false | ||
|
||
env: | ||
create-npmrc: ${{ secrets.scope != '' || secrets.registry-url != '' || secrets.auth-token != '' }} | ||
use-global-registry: ${{ secrets.scope == '' && secrets.registry-url != '' }} | ||
use-scope-registry: ${{ secrets.scope != '' && secrets.registry-url != '' }} | ||
use-standard-authentication: ${{ secrets.auth-token != '' && inputs.jfrog-artifactory == false }} | ||
use-jfrog-artifactory-authentication: ${{ secrets.auth-token != '' && inputs.jfrog-artifactory == true }} | ||
|
||
jobs: | ||
setup: | ||
name: Setup for Node.js ${{ inputs.node-version }} | ||
runs-on: ${{ inputs.os }} | ||
|
||
steps: | ||
- name: Checkout repository ${{ inputs.branch-ref }} | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ inputs.branch-ref }} | ||
token: ${{ secrets.github-token || github.token }} | ||
|
||
- name: Install Node.js ${{ inputs.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
|
||
# Generate .npmrc manually so it part of the cache and thus accessible to other reusable workflows | ||
- name: Generate .npmrc | ||
if: ${{ env.create-npmrc == 'true' }} | ||
shell: bash | ||
run: | | ||
SCOPE=${{ secrets.scope }} | ||
REGISTRY=$([[ "${{ secrets.registry-url }}" != "" ]] && echo "${{ secrets.registry-url }}" || echo "https://registry.npmjs.org/") | ||
AUTH=${{ secrets.auth-token }} | ||
if [ "${{ env.use-global-registry }}" == "true" ]; then | ||
echo "registry=${REGISTRY}" >> .npmrc; | ||
fi | ||
if [ "${{ env.use-scope-registry }}" == "true" ]; then | ||
echo "${SCOPE}:registry=${REGISTRY}" >> .npmrc; | ||
fi | ||
if [ "${{ env.use-standard-authentication }}" == "true" ]; then | ||
echo "//${REGISTRY##*//}:_authToken=${AUTH}" >> .npmrc | ||
fi | ||
if [ "${{ env.use-jfrog-artifactory-authentication }}" == "true" ]; then | ||
echo "//${REGISTRY##*//}:_auth=${AUTH}" >> .npmrc | ||
fi | ||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Create cache | ||
uses: actions/cache@v3 | ||
id: checkout-repository-cache | ||
with: | ||
path: ./* | ||
key: checkout-repository-cache-${{ github.sha }} |