Revert "Revert "Utilisation du CI de GitHub pour le déploiement Netlify (#1249)""

This reverts commit 7f9bf69603.
pull/1256/head
Maxime Quandalle 2020-12-02 09:34:21 +01:00
parent 7f9bf69603
commit d5838d3541
6 changed files with 79 additions and 11 deletions

55
.github/workflows/netlify.yaml vendored Normal file
View File

@ -0,0 +1,55 @@
name: Déploiement sur Netlify
on:
pull_request:
types: [opened, synchronize]
env:
GITHUB_API_SECRET: ${{ secrets.GITHUB_TOKEN }}
INSEE_SIRENE_API_SECRET: ${{ secrets.INSEE_SIRENE_API_TOKEN }}
MATOMO_TOKEN: ${{ secrets.MATOMO_TOKEN }}
jobs:
build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- run: npm install yarn
- run: yarn install
- run: yarn workspace mon-entreprise build
- name: Deploy to Netlify
id: deploy-netlify
uses: nwtgck/actions-netlify@v1.1
with:
publish-dir: './mon-entreprise/dist'
netlify-config-path: ./netlify.toml
production-branch: master
github-token: ${{ secrets.GITHUB_TOKEN }}
enable-commit-comment: false
# Disabled because we create our own customized comment
enable-pull-request-comment: false
alias: deploy-preview-${{ github.event.number }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
- name: Find Comment
uses: peter-evans/find-comment@v1
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }} #e.g. 1
comment-author: 'github-actions[bot]'
body-includes: netlify
- name: Create comment
if: ${{ steps.find-comment.outputs.comment-id == 0 }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
🚀 La branche est déployée ! ${{ steps.deploy-netlify.outputs.deploy-url }}
_Voir aussi : [version anglaise](${{ steps.deploy-netlify.outputs.deploy-url }}?s=m) | [site publicodes](${{ steps.deploy-netlify.outputs.deploy-url }}?s=p)_

View File

@ -1,4 +1,5 @@
# This bot post a comment when issues with a given label are closed.
name: Message du robot Zammad
on:
issues:
types: [closed]

View File

@ -50,16 +50,20 @@ import redirects from './redirects'
import { constructLocalizedSitePath } from './sitePaths'
if (process.env.NODE_ENV === 'production') {
let branch: string | undefined = process.env.GITHUB_REF?.split('/')?.slice(
-1
)?.[0]
if (branch === 'merge') {
branch = process.env.GITHUB_HEAD_REF
}
const release =
process.env.HEAD &&
process.env.COMMIT_REF &&
process.env.HEAD + '-' + process.env.COMMIT_REF?.substring(0, 7)
branch && `${branch}-` + process.env.GITHUB_SHA?.substring(0, 7)
const dsn = 'https://9051375f856646d694943532caf2b45f@sentry.data.gouv.fr/18'
Sentry.init({ dsn, release })
if (process.env.HEAD && process.env.HEAD !== 'master') {
if (branch && branch !== 'master') {
console.log(
` Vous êtes sur la branche : %c${process.env.HEAD}`,
` Vous êtes sur la branche : %c${branch}`,
'font-weight: bold; text-decoration: underline;'
)
}

View File

@ -5,10 +5,10 @@ declare namespace NodeJS {
NODE_ENV: 'development' | 'production' | 'test'
ANALYZE_BUNDLE: '0' | '1'
// Netlify variables
// https://docs.netlify.com/configure-builds/environment-variables/#read-only-variables
HEAD: string
COMMIT_REF: string
// Github actions env variables
// https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables
GITHUB_REF: string
GITHUB_SHA: string
// .env variables
GITHUB_API_SECRET: string

View File

@ -34,7 +34,11 @@ module.exports.default = {
EN_SITE: '/infrance${path}',
FR_SITE: '/mon-entreprise${path}'
}),
new EnvironmentPlugin({ HEAD: '', COMMIT_REF: '' }),
new EnvironmentPlugin({
GITHUB_REF: '',
GITHUB_HEAD_REF: '',
GITHUB_SHA: ''
}),
new CopyPlugin([
'./manifest.webmanifest',
{

View File

@ -17,7 +17,11 @@ module.exports = {
},
plugins: [
new MonacoWebpackPlugin(),
new EnvironmentPlugin({ HEAD: '', COMMIT_REF: '' }),
new EnvironmentPlugin({
GITHUB_REF: '',
GITHUB_HEAD_REF: '',
GITHUB_SHA: ''
}),
new EnvironmentPlugin({
EN_SITE: '/infrance${path}',
FR_SITE: '/mon-entreprise${path}'