diff --git a/.github/workflows/add-test-tag.yml b/.github/workflows/add-test-tag.yml new file mode 100644 index 00000000..81515bfe --- /dev/null +++ b/.github/workflows/add-test-tag.yml @@ -0,0 +1,30 @@ +on: + pull_request: + types: [synchronize] + +name: Add test tag + +jobs: + tag: + name: Add test tag + runs-on: ubuntu-latest + if: startsWith(github.event.pull_request.head.ref, 'release/') + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-git-comment-action@v1 + - name: Get version + run: echo "::set-env name=TAG_NAME::${HEAD_REF#release/}" + env: + HEAD_REF: ${{ github.event.pull_request.head.ref }} + if: contains(env.COMMIT_MESSAGE, 'trigger workflow') + - uses: actions/github-script@0.4.0 + with: + github-token: ${{ secrets.ACCESS_TOKEN }} + script: | + github.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: `refs/tags/test/${process.env.TAG_NAME}`, + sha: context.sha + }) + if: contains(env.COMMIT_MESSAGE, 'trigger workflow') diff --git a/.github/workflows/add-version-tag.yml b/.github/workflows/add-version-tag.yml index 37e9ad9d..e0facb7d 100644 --- a/.github/workflows/add-version-tag.yml +++ b/.github/workflows/add-version-tag.yml @@ -7,9 +7,10 @@ on: name: Add version tag jobs: - release: + tag: + name: Add version tag runs-on: ubuntu-latest - if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') + if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') steps: - name: Get version run: echo "::set-env name=TAG_NAME::${HEAD_REF#release/}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bcfbcef..70ba7abd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -175,22 +175,34 @@ jobs: matrix: target: ['npm', 'gpr'] steps: + - name: Set running flag + run: echo "::set-env name=RUNNING::1" + - name: Set running flag + run: | + if [ -z "$NPM_AUTH_TOKEN" ]; then + echo "::set-env name=RUNNING::" + fi + env: + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + - uses: actions/checkout@v2 + if: env.RUNNING - name: Setup Node.js uses: actions/setup-node@v1 with: node-version: 12 registry-url: https://registry.npmjs.org/ - if: matrix.target == 'npm' + if: env.RUNNING && matrix.target == 'npm' - name: Setup Node.js uses: actions/setup-node@v1 with: node-version: 12 registry-url: https://npm.pkg.github.com - if: matrix.target == 'gpr' + if: env.RUNNING && matrix.target == 'gpr' - name: Get Yarn Cache Directory id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" + if: env.RUNNING - name: Cache node dependencies uses: actions/cache@v1 with: @@ -198,34 +210,32 @@ jobs: key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - + if: env.RUNNING - name: Check package version uses: technote-space/package-version-check-action@v1 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMMIT_DISABLED: 1 + if: env.RUNNING - name: Install Package dependencies run: yarn install + if: env.RUNNING - name: Build run: yarn build + if: env.RUNNING - name: Publish run: | - if [ -n "$NPM_AUTH_TOKEN" ]; then - npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN - npm publish - fi + npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN + npm publish env: NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - if: matrix.target == 'npm' + if: env.RUNNING && matrix.target == 'npm' - name: Publish run: | - if [ -n "$NPM_AUTH_TOKEN" ]; then - npm publish - fi + npm publish env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - if: matrix.target == 'gpr' + if: env.RUNNING && matrix.target == 'gpr' - uses: 8398a7/action-slack@v2 with: status: failure diff --git a/.github/workflows/pr-updated.yml b/.github/workflows/pr-updated.yml index 847c3848..98b9d810 100644 --- a/.github/workflows/pr-updated.yml +++ b/.github/workflows/pr-updated.yml @@ -6,7 +6,7 @@ jobs: triage: name: Pull Request Labeler runs-on: ubuntu-latest - if: "! startsWith(github.event.pull_request.head.ref, 'release/v')" + if: "! startsWith(github.event.pull_request.head.ref, 'release/')" steps: - name: Pull Request Labeler uses: actions/labeler@v2