diff --git a/.github/.npmrc b/.github/.npmrc new file mode 100644 index 0000000..2980411 --- /dev/null +++ b/.github/.npmrc @@ -0,0 +1,2 @@ +save-exact=true +//registry.npmjs.org/:_authToken=${NPM_TOKEN} \ No newline at end of file diff --git a/.github/actions/setup-dependencies/action.yml b/.github/actions/setup-dependencies/action.yml new file mode 100644 index 0000000..8729fe8 --- /dev/null +++ b/.github/actions/setup-dependencies/action.yml @@ -0,0 +1,33 @@ +name: Setup +description: 'Setup dependencies and run tests' + +inputs: + github_token: + description: 'Github token for coveralls' + required: true + +runs: + using: "composite" + steps: + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: '10' + registry-url: 'https://registry.npmjs.org' + + - name: Install yarn + shell: bash + run: npm install -g yarn + + - name: Install dependencies + shell: bash + run: yarn install + + - name: Run tests + shell: bash + run: yarn test:cover + + - name: Run coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ inputs.github_token }} \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..bd899cb --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,71 @@ +name: Publish + +on: pull_request +#on: +# push: +# tags: +# - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup dependencies and run tests + uses: ./.github/actions/setup-dependencies + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Fetch npm token + id: secrets + uses: hashicorp/vault-action@v2.4.0 + with: + url: https://vault.jimdo-platform.net + method: jwt + role: github_jimdo + exportEnv: false + secrets: | + secret/creator/npm-publish-token NPM_TOKEN | NPM_PUBLISH_TOKEN; + + - name: Get latest tag + id: latest_tag + uses: WyriHaximus/github-action-get-previous-tag@v1 + + - name: Publish + run: | + npm config set git-tag-version=false + npm version ${{ steps.latest_tag.outputs.tag }} + npm publish + env: + NPM_TOKEN: ${{ steps.secrets.outputs.NPM_PUBLISH_TOKEN }} + + slack-workflow-status: + name: Post workflow status to Slack + needs: + - publish + if: always() + runs-on: ubuntu-latest + steps: + - name: Determine if we need to notify + uses: Jimdo/should-i-notify-action@main + id: should_notify + with: + branch: master + needs_context: ${{ toJson(needs) }} + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Slack workflow notification + uses: Gamesight/slack-workflow-status@master + if: steps.should_notify.outputs.should_send_message == 'yes' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} + channel: 'creator-deployments' + name: 'serverless-dotenv' \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d871236 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: CI + +on: + push: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup dependencies and run tests + uses: ./.github/actions/setup-dependencies + with: + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index b9651a9..2f0ff97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ coverage node_modules *.log +.idea diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 7d83aab..0000000 --- a/circle.yml +++ /dev/null @@ -1,31 +0,0 @@ -machine: - node: - version: 4.5.0 - environment: - PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin" - -dependencies: - pre: - - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - - override: - - yarn - - post: - - yarn global add dot-json - - cache_directories: - - ~/.cache/yarn - -test: - override: - - yarn test:cover - post: - - yarn coveralls - -deployment: - production: - tag: /v[0-9]+(\.[0-9]+)*$/ - commands: - - dot-json package.json version ${CIRCLE_TAG:1} - - npm publish