Skip to content

Commit

Permalink
chore: CI workflow improvements (#2380)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Apr 25, 2024
1 parent d10dc62 commit 0a8aa74
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 38 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Expand Up @@ -11,19 +11,19 @@ jobs:

if: github.repository_owner == 'visgl'

permissions:
contents: write

env:
ADMIN_TOKEN: ${{ secrets.ADMIN_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2.1.1

- name: Get git tags (https://github.com/actions/checkout/issues/206)
run: git fetch --tags -f
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: '16.x'
node-version: '18.x'

- name: Publish release
run: |
Expand All @@ -33,4 +33,4 @@ jobs:
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/visgl/react-map-gl/releases \
-d "${body}" \
-H "Authorization: token ${ADMIN_TOKEN}"
-H "Authorization: token ${GITHUB_TOKEN}"
13 changes: 6 additions & 7 deletions .github/workflows/test.yml
Expand Up @@ -11,26 +11,25 @@ jobs:
test-node:
runs-on: ubuntu-latest

env:
VITE_MAPBOX_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN_CI }}

steps:
- uses: actions/checkout@v2.1.1
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: '16.x'
node-version: '18.x'

- name: Install dependencies
run: |
yarn bootstrap
- name: Run tests
env:
VITE_MAPBOX_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN_CI }}
run: |
yarn test ci
- name: Coveralls
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@09b709cf6a16e30b0808ba050c7a6e8a5ef13f8d # v1.2.5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
53 changes: 31 additions & 22 deletions .github/workflows/website.yml
Expand Up @@ -6,42 +6,51 @@ on:
- '*-release'

jobs:
publish-website:
check_branch:
runs-on: ubuntu-latest
outputs:
should_deploy: ${{ endsWith(github.ref, steps.get_version.outputs.latest) }}

if: github.repository_owner == 'visgl'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Get version
id: get_version
run: |
LATEST=$(npm show react-map-gl version | grep -o -E "^[0-9]+\.[0-9]+")
echo "latest=${LATEST}-release" >> "$GITHUB_OUTPUT"
deploy:
runs-on: ubuntu-latest
needs: check_branch

permissions:
contents: write

env:
MapboxAccessToken: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
if: ${{ github.repository_owner == 'visgl' && needs.check_branch.outputs.should_deploy }}

steps:
- uses: actions/checkout@v2.1.1
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
token: ${{ secrets.WEBSITE_DEPLOY_TOKEN }}

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: '16.x'

- name: Get version
id: get-version
run: LATEST=$(npm show react-map-gl version | grep -o -E "^[0-9]+\.[0-9]+") && echo "::set-output name=latest::/${LATEST}-release"
node-version: '18.x'

- name: Check version
if: ${{ !endsWith(github.ref, steps.get-version.outputs.latest) }}
- name: Install dependencies
run: |
echo "Website is only published from the latest release branch"
yarn bootstrap
(cd website && yarn)
- name: Build website
if: ${{ endsWith(github.ref, steps.get-version.outputs.latest) }}
run: |
yarn bootstrap
cd website
yarn
yarn build
env:
MapboxAccessToken: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
run: (cd website && yarn build)

- name: Deploy
if: ${{ endsWith(github.ref, steps.get-version.outputs.latest) }}
uses: JamesIves/github-pages-deploy-action@3.7.1
uses: JamesIves/github-pages-deploy-action@132898c54c57c7cc6b80eb3a89968de8fc283505 # 3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
Expand Down
2 changes: 1 addition & 1 deletion scripts/github-release.js
Expand Up @@ -28,7 +28,7 @@ console.log(JSON.stringify(requestBody));

function getGitTag() {
try {
return execSync('git describe --exact-match HEAD', {
return execSync('git describe --tags --exact-match HEAD', {
stdio: [null, 'pipe', null],
encoding: 'utf-8'
}).trim();
Expand Down

0 comments on commit 0a8aa74

Please sign in to comment.