Replace Doctrine Fixtures with Alice #1959
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- master # triggers on pushes that contain changes in master | |
- develop | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
path: 'kiwi' | |
- name: Set PHP version | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.1' | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Move public for build | |
if: github.ref == 'refs/heads/master' | |
run: | | |
egrep -lRZ 'public/' kiwi | xargs -0 -l sed -i -e 's/public\//..\/public_html\/kiwi\//g' | |
sed -i -e 's/\/vendor\/autoload_runtime.php/\/..\/kiwi\/vendor\/autoload_runtime.php/g' kiwi/public/index.php | |
sed -i -e 's/\"extra\": {/\"extra\": {\n \"public-dir\": \"..\/public_html\/kiwi\",/g' kiwi/composer.json | |
mkdir public_html | |
mv kiwi/public public_html/kiwi | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress --no-suggest --no-dev --optimize-autoloader | |
working-directory: kiwi | |
env: | |
APP_DEBUG: 0 | |
APP_ENV: prod | |
- name: Install JS dependencies | |
run: yarn install | |
working-directory: kiwi | |
- name: Build JS dependencies | |
run: yarn build | |
working-directory: kiwi | |
- name: Extract platform requirements composer.lock | |
if: github.ref == 'refs/heads/master' | |
run: "composer check-platform-reqs --working-dir ./kiwi --lock --no-dev --no-ansi 2>&1 | sed '1,1d' | tr '\n' ',' | sed 's/.$//' | jq -R 'split(\",\") | map(. | gsub(\" +\"; \" \") | split(\" \") | { key: .[0], value: .[1] }) | from_entries' > requirements.json" | |
- name: Upload requirements file | |
uses: actions/upload-artifact@v4 | |
if: github.ref == 'refs/heads/master' | |
with: | |
name: requirements | |
path: requirements.json | |
- name: Cleanup build | |
if: github.ref == 'refs/heads/master' | |
run: | | |
rm kiwi/{,.[!.],..?}* 2> /dev/null || true | |
rm -rf kiwi/.git | |
rm -rf kiwi/.github | |
rm -rf kiwi/.hooks | |
rm -rf kiwi/assets | |
rm -rf kiwi/bin | |
rm -rf kiwi/node_modules | |
rm -rf kiwi/tests | |
rm -rf kiwi/var | |
- name: Generate sample environment settings for build | |
if: github.ref == 'refs/heads/master' | |
run: | | |
cat > kiwi/.env.local.php.sample << EOL | |
<?php | |
return array ( | |
'APP_DEBUG' => '0', | |
'APP_ENV' => 'prod', | |
'APP_SECRET' => '6fake_app_secrit_dont_look4', | |
'USERPROVIDER_KEY' => 'ThisIsNotSoSecret', | |
'DATABASE_URL' => 'mysql://db_user:db_pass@127.0.0.1:3306/db', | |
'MAILER_URL' => 'null://null', | |
'DEFAULT_FROM' => 'foo@bar.com', | |
); | |
EOL | |
- name: Compress build | |
if: github.ref == 'refs/heads/master' | |
run: zip -qq -r prod.zip kiwi public_html | |
- name: Upload build | |
uses: actions/upload-artifact@v4 | |
if: github.ref == 'refs/heads/master' | |
with: | |
name: prod | |
path: prod.zip | |
release: | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Get current date | |
uses: actions/github-script@0.3.0 | |
id: author-date | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
const commit_details = await github.git.getCommit({owner: context.repo.owner, repo: context.repo.repo, commit_sha: context.sha}); | |
const d = new Date(commit_details.data.author.date) | |
function pad(s) { return (s < 10) ? '0' + s : s; } | |
return [d.getFullYear(), pad(d.getMonth()+1), pad(d.getDate())].join('-') | |
- id: formatted-date | |
run: | | |
date="${DATE//\"/}" | |
echo "::set-output name=result::$date" | |
env: | |
DATE: ${{ steps.author-date.outputs.result }} | |
- name: Download build | |
uses: actions/download-artifact@v4 | |
with: | |
name: prod | |
path: . | |
- name: Download requirements | |
uses: actions/download-artifact@v4 | |
with: | |
name: requirements | |
path: . | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DATE: ${{ steps.formatted-date.outputs.result }} | |
with: | |
tag_name: ${{ env.DATE }} | |
release_name: Release ${{ env.DATE }} | |
draft: true | |
prerelease: false | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: prod.zip | |
asset_name: kiwi.zip | |
asset_content_type: application/zip | |
- name: Upload Requirements Asset | |
id: upload-requirements-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: requirements.json | |
asset_name: requirements.json | |
asset_content_type: application/json | |
- name: Publish Release | |
id: publish_release | |
uses: eregon/publish-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.KIWIRELEASETOKEN }} | |
with: | |
release_id: ${{ steps.create_release.outputs.id }} |