Skip to content

Commit

Permalink
Don't push on gh-pages concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jan 3, 2022
1 parent c845ec1 commit 4730091
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 74 deletions.
58 changes: 51 additions & 7 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:

env:
HAS_SECRETS: ${{ secrets.HAS_SECRETS }}
MAIN_BRANCH: master
CI: true

jobs:
not-failed-backport:
Expand All @@ -26,8 +28,6 @@ jobs:
if: "!startsWith(github.event.head_commit.message, '[skip ci] ')"

env:
MAIN_BRANCH: master
CI: true
PATH: /bin:/usr/bin:/usr/local/bin:/home/runner/.local/bin

steps:
Expand Down Expand Up @@ -121,16 +121,12 @@ jobs:

- run: make transifex-send
if: env.HAS_SECRETS == 'HAS_SECRETS' && github.ref == format('refs/heads/{0}', env.MAIN_BRANCH)
- run: buildtools/publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: env.HAS_SECRETS == 'HAS_SECRETS'
- run: buildtools/npm-publish
if: env.HAS_SECRETS == 'HAS_SECRETS' && github.event_name == 'push'

- name: Publish Storybook to Chromatic to run visual tests
run: npm run chromatic -- --project-token=$(gopass show gs/ci/chromatic/ngeo_token)
if: env.HAS_SECRETS == 'HAS_SECRETS' && github.event_name != 'pull_request_target'
if: env.HAS_SECRETS == 'HAS_SECRETS' && github.event_name == 'push'
- name: Publish Storybook to Chromatic to run visual tests
run: GITHUB_SHA=${GITHUB_SHA_} npm run chromatic -- --project-token=$(gopass show gs/ci/chromatic/ngeo_token) --branch-name=${GITHUB_HEAD_REF}
if: env.HAS_SECRETS == 'HAS_SECRETS' && github.event_name == 'pull_request_target'
Expand All @@ -147,3 +143,51 @@ jobs:
if: >
github.ref == format('refs/heads/{0}', env.MAIN_BRANCH)
&& env.HAS_SECRETS == 'HAS_SECRETS'
- name: Prepare gh-pages
run: |
mkdir -p gh-pages
cp -ar api/dist gh-pages/api
cp -ar apidoc gh-pages/apidoc
cp -ar .build/examples-hosted gh-pages/examples
cp -ar .build/storybook gh-pages/storybook
if: startsWith(github.ref, 'refs/heads/') && ! contains(github.ref_name, '/') && env.HAS_SECRETS == 'HAS_SECRETS'

- uses: actions/upload-artifact@v2
with:
name: gh-pages
path: gh-pages
if: startsWith(github.ref, 'refs/heads/') && ! contains(github.ref_name, '/') && env.HAS_SECRETS == 'HAS_SECRETS'

gh-pages:
runs-on: ubuntu-20.04
name: Github Pages
timeout-minutes: 10
if: startsWith(github.ref, 'refs/heads/') && ! contains(github.ref_name, '/')
concurrency: gh-pages
needs:
- main

steps:
- uses: actions/checkout@v2
with:
ref: gh-pages
fetch-depth: 0
if: env.HAS_SECRETS == 'HAS_SECRETS'

- uses: actions/download-artifact@v2
with:
name: gh-pages
path: ${{ github.ref_name }}
if: env.HAS_SECRETS == 'HAS_SECRETS'

- name: Rewrite root commit and force push
run: |
git config --global user.name "Continuous integration"
git config --global user.email "[email protected]"
FIRST_COMMIT=$(git log --format='%H' | tail -1)
git reset --quiet --mixed $FIRST_COMMIT
git add ${{ github.ref_name }}
git commit --quiet --amend --message="Update GitHub pages"
git push --force
if: env.HAS_SECRETS == 'HAS_SECRETS'
1 change: 1 addition & 0 deletions .github/workflows/test_url.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
body: [
\`Examples: https://camptocamp.github.io/ngeo/\${process.env.GITHUB_HEAD_REF}/examples/\`,
\`Storybook: https://camptocamp.github.io/ngeo/\${process.env.GITHUB_HEAD_REF}/storybook/\`,
\`API help: https://camptocamp.github.io/ngeo/\${process.env.GITHUB_HEAD_REF}/api/apihelp/apihelp.html\`,
\`API documentation: https://camptocamp.github.io/ngeo/\${process.env.GITHUB_HEAD_REF}/apidoc/\`,
].join('\n'),
event: 'COMMENT'
Expand Down
66 changes: 0 additions & 66 deletions buildtools/publish

This file was deleted.

4 changes: 3 additions & 1 deletion buildtools/webpack.api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) 2018-2021 Camptocamp SA
// Copyright (c) 2018-2022 Camptocamp SA
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -47,6 +47,7 @@ module.exports = (env, argv) => {
rules: [
{
test: /\.js$/,
exclude: [/(core-js|strip-ansi)/],
use: {
loader: 'babel-loader',
options: {
Expand All @@ -61,6 +62,7 @@ module.exports = (env, argv) => {
output: {
filename: 'api.js',
path: dest,
libraryTarget: 'umd',
libraryExport: 'default',
library: library,
},
Expand Down

0 comments on commit 4730091

Please sign in to comment.