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' |
24 | jobs: |
25 | runregen: |
26 | runs-on: ubuntu-latest |
27 | name: Run Regen |
28 | services: |
29 | mysql: |
30 | image: mysql:8.0 |
31 | env: |
32 | MYSQL_ALLOW_EMPTY_PASSWORD: no |
33 | MYSQL_DATABASE: db |
34 | MYSQL_ROOT_PASSWORD: passpasspw |
35 | ports: |
36 | - 3306 |
37 | options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
38 | steps: |
39 | - uses: shivammathur/setup-php@v2 |
40 | with: |
41 | php-version: 7.4 |
42 | extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, soap, intl, gd, exif, iconv |
43 | coverage: none |
44 | tools: composer:v2 |
45 | - name: Sanity check |
46 | run: | |
47 | if [ "$GITHUB_REPOSITORY" = "civicrm/civicrm-core" ]; then |
48 | echo "You need to run this in your own fork." |
49 | exit -1 |
50 | fi |
51 | - name: Download cv |
52 | run: | |
53 | cd $GITHUB_WORKSPACE |
54 | git clone https://github.com/civicrm/cv.git civicrm-cv |
55 | cd civicrm-cv |
56 | # downloads-plugin is locked at 2.1 but that doesn't work with composer v2 |
57 | rm composer.lock |
58 | COMPOSER_MEMORY_LIMIT=-1 composer install |
59 | - name: Download and install stuff |
60 | run: | |
61 | cd $GITHUB_WORKSPACE |
62 | export DRUPVER=`php -r '$xml = simplexml_load_file("https://updates.drupal.org/release-history/drupal/7.x"); echo $xml->releases[0]->release->version;'` |
63 | curl -L -o drupal.tgz https://ftp.drupal.org/files/projects/drupal-$DRUPVER.tar.gz |
64 | tar xzf drupal.tgz |
65 | mv drupal-$DRUPVER drupal |
66 | cd drupal |
67 | composer require drush/drush:'^8' |
68 | ./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 |
69 | chmod +w sites/default |
70 | cd sites/all/modules |
71 | # check out my fork's branch as selected from the dropdown |
72 | BRANCHNAME=${GITHUB_REF##*/} |
73 | echo "Cloning branch $BRANCHNAME from $GITHUB_SERVER_URL/$GITHUB_REPOSITORY" |
74 | git clone -b $BRANCHNAME --depth 1 $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git civicrm |
75 | cd civicrm |
76 | git clone -b 7.x-${{ github.event.inputs.civiver }} --depth 1 https://github.com/civicrm/civicrm-drupal.git drupal |
77 | git clone -b ${{ github.event.inputs.civiver }} --depth 1 https://github.com/civicrm/civicrm-packages.git packages |
78 | COMPOSER_MEMORY_LIMIT=-1 composer install |
79 | npm install |
80 | cd xml |
81 | php GenCode.php |
82 | cd .. |
83 | $GITHUB_WORKSPACE/civicrm-cv/bin/cv core:install --cms-base-url=http://civi.localhost |
5fa01ef4 |
84 | # 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. |
85 | echo '<?php define("CIVICRM_CONFDIR", "/home/runner/work/civicrm-core/civicrm-core/drupal/sites/default");' > settings_location.php |
4397a725 |
86 | - name: regen |
87 | run: | |
88 | cd $GITHUB_WORKSPACE/drupal/sites/all/modules/civicrm/bin |
89 | export PATH=$PATH:$GITHUB_WORKSPACE/drupal/vendor/drush/drush |
90 | cp setup.conf.txt setup.conf |
91 | sed -i -e "s#CIVISOURCEDIR=#CIVISOURCEDIR=$GITHUB_WORKSPACE/drupal/sites/all/modules/civicrm#" setup.conf |
92 | sed -i -e 's/DBUSER=/DBUSER=root/' setup.conf |
93 | sed -i -e 's/DBPASS=/DBPASS=passpasspw/' setup.conf |
94 | sed -i -e 's/DBNAME=/DBNAME=db/' setup.conf |
95 | sed -i -e 's/DBHOST=/DBHOST=127.0.0.1/' setup.conf |
96 | sed -i -e 's/DBPORT=/DBPORT=${{ job.services.mysql.ports[3306] }}/' setup.conf |
97 | sed -i -e 's/GENCODE_CMS=""/GENCODE_CMS=Drupal/' setup.conf |
98 | # next two lines just make it easier to see what's going on if it fails |
99 | cat setup.conf |
100 | sed -i -e 's/set -e/set -e\nset -x/' setup.sh |
101 | cd .. |
102 | bin/regen.sh |
103 | - name: maybe commit |
104 | if: ${{ success() && github.event.inputs.autocommit == 'y' }} |
105 | run: | |
106 | cd $GITHUB_WORKSPACE/drupal/sites/all/modules/civicrm |
107 | git config --global user.name "$GITHUB_ACTOR" |
108 | git config --global user.email "regen@civicrm.org" |
109 | # We don't use `-a` because often there's other files that get spurious updates like composer.lock |
110 | git commit -m "regenerate civicrm_generated" sql/civicrm_generated.mysql |
111 | git remote add mine https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git |
112 | git push mine |
113 | - uses: actions/upload-artifact@v2 |
114 | if: ${{ success() }} |
115 | with: |
116 | name: the_file_you_requested |
117 | path: '/home/runner/work/civicrm-core/civicrm-core/drupal/sites/all/modules/civicrm/sql/civicrm_generated.mysql' |