4397a725 |
1 | # Helper to run bin/regen.sh to regenerate civicrm_generated.mysql |
2 | # 1. In your civicrm-core fork on github.com, click on the Actions tab. |
3 | # 2. Click on Regen on the left. |
4 | # 3. On the right you'll see a dropdown "Run workflow". |
5 | # 4. From the Branch field in the dropdown pick your branch. |
6 | # 5. Optionally choose to have it add a commit with the new file to your branch at the end, otherwise it will give you the file to download. |
7 | # Note it does not autosquash but typically this would be done at the end and is acceptable as its own commit. |
8 | # 6. Wait about 2-3 minutes until the spinning yellow turns green. |
9 | # 7. If you didn't choose to commit, then to get to the download click on the green. |
10 | # 7. Scroll down to Artifacts. |
11 | # 8. There's your file available for download. |
12 | name: Regen |
13 | on: |
14 | workflow_dispatch: |
15 | inputs: |
16 | civiver: |
17 | description: CiviCRM version |
18 | required: true |
19 | default: 'master' |
20 | autocommit: |
21 | description: Autocommit to branch (y or n) |
22 | required: false |
23 | default: 'n' |
59bff4f1 |
24 | permissions: |
25 | contents: read |
26 | |
4397a725 |
27 | jobs: |
28 | runregen: |
59bff4f1 |
29 | permissions: |
30 | contents: write # for Git to git push |
4397a725 |
31 | runs-on: ubuntu-latest |
32 | name: Run Regen |
33 | services: |
34 | mysql: |
35 | image: mysql:8.0 |
36 | env: |
37 | MYSQL_ALLOW_EMPTY_PASSWORD: no |
38 | MYSQL_DATABASE: db |
39 | MYSQL_ROOT_PASSWORD: passpasspw |
40 | ports: |
41 | - 3306 |
42 | options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
43 | steps: |
44 | - uses: shivammathur/setup-php@v2 |
45 | with: |
46 | php-version: 7.4 |
47 | extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, soap, intl, gd, exif, iconv |
48 | coverage: none |
49 | tools: composer:v2 |
50 | - name: Sanity check |
51 | run: | |
52 | if [ "$GITHUB_REPOSITORY" = "civicrm/civicrm-core" ]; then |
53 | echo "You need to run this in your own fork." |
54 | exit -1 |
55 | fi |
56 | - name: Download cv |
57 | run: | |
58 | cd $GITHUB_WORKSPACE |
59 | git clone https://github.com/civicrm/cv.git civicrm-cv |
60 | cd civicrm-cv |
61 | # downloads-plugin is locked at 2.1 but that doesn't work with composer v2 |
62 | rm composer.lock |
63 | COMPOSER_MEMORY_LIMIT=-1 composer install |
64 | - name: Download and install stuff |
65 | run: | |
66 | cd $GITHUB_WORKSPACE |
67 | export DRUPVER=`php -r '$xml = simplexml_load_file("https://updates.drupal.org/release-history/drupal/7.x"); echo $xml->releases[0]->release->version;'` |
68 | curl -L -o drupal.tgz https://ftp.drupal.org/files/projects/drupal-$DRUPVER.tar.gz |
69 | tar xzf drupal.tgz |
70 | mv drupal-$DRUPVER drupal |
71 | cd drupal |
72 | composer require drush/drush:'^8' |
73 | ./vendor/drush/drush/drush -y -l http://civi.localhost site-install standard --db-url='mysql://root:passpasspw@127.0.0.1:${{ job.services.mysql.ports[3306] }}/db' --site-name=TestCivi --account-pass=admin |
74 | chmod +w sites/default |
75 | cd sites/all/modules |
76 | # check out my fork's branch as selected from the dropdown |
77 | BRANCHNAME=${GITHUB_REF##*/} |
78 | echo "Cloning branch $BRANCHNAME from $GITHUB_SERVER_URL/$GITHUB_REPOSITORY" |
79 | git clone -b $BRANCHNAME --depth 1 $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git civicrm |
80 | cd civicrm |
81 | git clone -b 7.x-${{ github.event.inputs.civiver }} --depth 1 https://github.com/civicrm/civicrm-drupal.git drupal |
82 | git clone -b ${{ github.event.inputs.civiver }} --depth 1 https://github.com/civicrm/civicrm-packages.git packages |
83 | COMPOSER_MEMORY_LIMIT=-1 composer install |
84 | npm install |
85 | cd xml |
86 | php GenCode.php |
87 | cd .. |
88 | $GITHUB_WORKSPACE/civicrm-cv/bin/cv core:install --cms-base-url=http://civi.localhost |
5fa01ef4 |
89 | # In this environment in this particular repo, we are under a workspace folder that contains the literal "civicrm-core" in the path, which makes civicrm.config.php think we are a composer install, so it gets the paths wrong. |
90 | echo '<?php define("CIVICRM_CONFDIR", "/home/runner/work/civicrm-core/civicrm-core/drupal/sites/default");' > settings_location.php |
4397a725 |
91 | - name: regen |
92 | run: | |
93 | cd $GITHUB_WORKSPACE/drupal/sites/all/modules/civicrm/bin |
94 | export PATH=$PATH:$GITHUB_WORKSPACE/drupal/vendor/drush/drush |
95 | cp setup.conf.txt setup.conf |
96 | sed -i -e "s#CIVISOURCEDIR=#CIVISOURCEDIR=$GITHUB_WORKSPACE/drupal/sites/all/modules/civicrm#" setup.conf |
97 | sed -i -e 's/DBUSER=/DBUSER=root/' setup.conf |
98 | sed -i -e 's/DBPASS=/DBPASS=passpasspw/' setup.conf |
99 | sed -i -e 's/DBNAME=/DBNAME=db/' setup.conf |
100 | sed -i -e 's/DBHOST=/DBHOST=127.0.0.1/' setup.conf |
101 | sed -i -e 's/DBPORT=/DBPORT=${{ job.services.mysql.ports[3306] }}/' setup.conf |
102 | sed -i -e 's/GENCODE_CMS=""/GENCODE_CMS=Drupal/' setup.conf |
103 | # next two lines just make it easier to see what's going on if it fails |
104 | cat setup.conf |
105 | sed -i -e 's/set -e/set -e\nset -x/' setup.sh |
106 | cd .. |
107 | bin/regen.sh |
108 | - name: maybe commit |
109 | if: ${{ success() && github.event.inputs.autocommit == 'y' }} |
110 | run: | |
111 | cd $GITHUB_WORKSPACE/drupal/sites/all/modules/civicrm |
112 | git config --global user.name "$GITHUB_ACTOR" |
113 | git config --global user.email "regen@civicrm.org" |
114 | # We don't use `-a` because often there's other files that get spurious updates like composer.lock |
115 | git commit -m "regenerate civicrm_generated" sql/civicrm_generated.mysql |
116 | git remote add mine https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git |
117 | git push mine |
118 | - uses: actions/upload-artifact@v2 |
119 | if: ${{ success() }} |
120 | with: |
121 | name: the_file_you_requested |
122 | path: '/home/runner/work/civicrm-core/civicrm-core/drupal/sites/all/modules/civicrm/sql/civicrm_generated.mysql' |