Skip to content

Commit

Permalink
CI/CD - Push to CDN (#48)
Browse files Browse the repository at this point in the history
* Publish workflow
  • Loading branch information
MaxencePerrinPrestashop authored Dec 15, 2020
1 parent 1a61322 commit 7e457c7
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 45 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/npm-publish.yml

This file was deleted.

71 changes: 71 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: NPM Publish / CDN Publish

on:
push:
tags:
- '*'

jobs:
npm-publish:
name: NPM Publish and CDN publish
runs-on: ubuntu-latest
steps:

- name: Get tag
id: get_tag
run: |
echo ::set-output name=TAG::$(echo $GITHUB_REF | cut -d / -f 3)
echo ::set-output name=MAJOR::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d '.' -f 1)
echo ::set-output name=MINOR::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d '.' -f 2)
echo ::set-output name=PATCH::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d '.' -f 3)
- name: Gcloud auth and write env file
run: |
echo $GOOGLE_APPLICATION_CREDENTIALS > token.json
gcloud auth activate-service-account --key-file=token.json
gcloud container clusters get-credentials $GCLOUD_CLUSTER \
--zone europe-west1-c --project psessentials-integration
gcloud auth configure-docker
rm token.json
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GCLOUD_CLUSTER: ${{ secrets.GCLOUD_CLUSTER }}

- name: Checkout repository
uses: actions/checkout@master

- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/

- name: Yarn install
uses: borales/[email protected]
with:
cmd: install

- name: Yarn build
uses: borales/[email protected]
with:
cmd: build-lib

- name: Update npm version
run: npm version $VERSION --no-git-tag-version --allow-same-version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
VERSION: ${{ steps.get_tag.outputs.TAG }}

- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- run: |
gsutil cp dist/psaccountsVue.umd.min.js gs://prestashop-vuejs-cdn/accounts/$MAJOR.$MINOR.$PATCH/prestashop_accounts_vue_components.min.js
gsutil cp dist/psaccountsVue.umd.min.js gs://prestashop-vuejs-cdn/accounts/x.$MINOR.$PATCH/prestashop_accounts_vue_components.min.js
gsutil cp dist/psaccountsVue.umd.min.js gs://prestashop-vuejs-cdn/accounts/x.x.$PATCH/prestashop_accounts_vue_components.min.js
env:
MAJOR: ${{ steps.get_tag.outputs.MAJOR }}
MINOR: ${{ steps.get_tag.outputs.MINOR }}
PATCH: ${{ steps.get_tag.outputs.PATCH }}

0 comments on commit 7e457c7

Please sign in to comment.