Pas moyen d’éviter que mon job d’intégration continue ne soit lancé plus qu’une seule fois au moment où je crée une release et j’ai beau tenter de limiter ça avec un :
on:
release:
type:
- released
J’ai encore et toujours 3 déclenchements !
Par ailleurs je viens de comprendre que la création de release sur Github passait en réalité par une (pseudo) branche et que du coup ça foutait le souk quand je voulais pousser une modif sur la branche principale depuis le job :
fatal: You are not currently on a branch. To push the history leading to the current (detached HEAD) state now, use git push origin HEAD:<name-of-remote-branch> Error: Process completed with exit code 128.
Et là ça sort de mes compétences avec Git et je ne trouve aucune doc ou exemple qui me permettrait de trouver comment obtenir ce que je voudrait.
Conclusion : je vais revenir à un déclenchement manuel et on verra plus tard…
Donc pour l’instant le job est comme ci-dessous :
name: Update cdstore.xml file if necessary
on: [workflow_dispatch]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "dcstore"
dcstore:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Setup PHP
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Run PHP code
- name: Run PHP code
id: getversion
shell: php {0}
run: |
<?php
$version = '';
$dcmin = '2.0';
if (file_exists('dcstore.xml')) {
$df = file_get_contents('./_define.php');
if (preg_match('/registerModule\((.*?),(.*?),(.*?),(.*?)\'(.*?)\'(.*?)(,.*)\)/s',$df,$matches)) {
if (isset($matches[5])) {
$version = $matches[5];
if (isset($matches[7])) {
$str = $matches[7];
if (preg_match('/\[(.*?)\'core\'(.*?),(.*?)\'(.*?)\'(.*?)\]/s',$str,$submatches)) {
$dcmin = $submatches[4];
}
}
}
}
if ($version !== '') {
$ds = file_get_contents('dcstore.xml');
if ($ds) {
$ds = preg_replace('/<version>(.*?)<\/version>/s',"<version>$version</version>",$ds);
$ds = preg_replace('/download\/(.*?)\//s',"download/$version/",$ds);
$ds = preg_replace('/(.*)-(.*?).zip/s',"$1-$version.zip",$ds);
$ds = preg_replace('/<da:dcmin>(.*?)<\/da:dcmin>/s',"<da:dcmin>$dcmin</da:dcmin>",$ds);
if ($ds) {
file_put_contents('dcstore.xml',$ds);
}
}
}
}
echo "::set-output name=module_version::$version\n";
echo "::set-output name=module_dcmin::$dcmin\n";
# Cope with returned version
- name: Log output of the script
run: echo "${{steps.getversion.outputs.module_version}} (Dotclear ${{steps.getversion.outputs.module_dcmin}}+)"
# Update dcstore.xml if necessary
- name: Update dcstore
id: update-dcstore
shell: bash
run: |
cat dcstore.xml
test=$(git diff --name-only -- dcstore.xml)
if [[ "$test" != "" ]]; then
echo "dcstore.xml modified, need to be commit"
git config --global user.email "bibi@moi.com"
git config --global user.name "bibi"
git add dcstore.xml
git commit -m "Update dcstore.xml - version ${{steps.getversion.outputs.module_version}} - Dotclear ${{steps.getversion.outputs.module_dcmin}}+"
git push
fi