Skip to content

Commit

Permalink
feat: new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
OverGlass committed Jan 7, 2025
1 parent 5f2d526 commit 50c31da
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 666 deletions.
27 changes: 19 additions & 8 deletions .github/scripts/announce.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
/// <reference types="node" />
/* eslint-env node */
/* global fetch, process */
/* eslint-disable no-console */

const payload = {
sender: 'github-actions',
type: process.env.EAS_WORKFLOW_TYPE,
branch: process.env.BRANCH_NAME,
domain: process.env.EXPO_PUBLIC_ASSOCIATED_DOMAIN,
last_commit_message: process.env.LAST_COMMIT_MESSAGE,
comment: process.env.WORFLOW_COMMENT_INPUT ?? null,
env: process.env.WORKFLOW_ENVIRONMENT,
}

const requestOptions = {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
channel: "#app-livraison",
text: `Déploiement terminé du projet mobile (${process.env.BRANCH_NAME}) sur : ${process.env.URL.replace('"', '').replace('\"', '')}`
})
};
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
}

fetch(process.env.SLACK_WEBHOOK_URL, requestOptions)
fetch(process.env.MAKE_WEBHOOK_URL, requestOptions)
86 changes: 0 additions & 86 deletions .github/scripts/build.mjs

This file was deleted.

74 changes: 74 additions & 0 deletions .github/scripts/eas-deploy.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/// <reference types="node" />
/* eslint-env node */
/* global console, process */
/* eslint-disable no-console */

import {exec} from 'child_process'
import {promisify} from 'util'
import chalk from 'chalk'
import appJson from '../../app.json' assert {type: 'json'}
import {fileURLToPath} from 'url'
import {program} from "commander";

/*
This app simplify the build run instead of running it directly on bash
*/


const aExec = promisify(exec)
const candidate = appJson.expo.version

// Declare non available features un mJS
const __filename = fileURLToPath(import.meta.url)


async function actionHandler() {
try {
console.log('REF TYPE IS', process.env.REF_TYPE, '\n')
switch (process.env.EAS_WORKFLOW_TYPE) {
case 'update': {
console.log(chalk.magenta(`Will do an UPDATE on expo runtime version ${candidate}.`))
const expoUpdateCommandBase = `eas update --auto`
await aExec(expoUpdateCommandBase)
process.exit(0)
break;
}
case 'build': {
const expoCommandBase = `eas build --platform all --non-interactive --no-wait`
if (process.env.WORKFLOW_ENVIRONMENT === 'production') {
console.log(chalk.magenta('Will do a build on production env...'))
await aExec(`${expoCommandBase} --profile production --auto-submit`)
process.exit(0)
}
if (process.env.WORKFLOW_ENVIRONMENT === 'staging') {
console.log(chalk.blue('Will do a build on staging env...'))
await aExec(`${expoCommandBase} --profile staging`)
process.exit(0)
}
console.log(chalk.red(`Unknown WORKFLOW_ENVIRONMENT ${process.env.WORKFLOW_ENVIRONMENT}`))
process.exit(2)
break;
}
default: {
console.log(chalk.red(`Unknown EAS_WORKFLOW_TYPE ${process.env.EAS_WORKFLOW_TYPE}`))
process.exit(2)
}
}
} catch (error) {
if (error instanceof Error) {
console.log(chalk.red(error.message))
} else {
console.log(chalk.red('Unknown error'))
}
process.exit(3)
}


}


program
.description('This app simplify the build run instead of running it directly on bash')
.action(actionHandler)
.parse()
48 changes: 0 additions & 48 deletions .github/scripts/isBuildOrUpdate.mjs

This file was deleted.

26 changes: 0 additions & 26 deletions .github/scripts/readAppVersion.mjs

This file was deleted.

38 changes: 0 additions & 38 deletions .github/scripts/update.mjs

This file was deleted.

Loading

0 comments on commit 50c31da

Please sign in to comment.