Skip to content

Commit

Permalink
Merge pull request #53 from clue-labs/github-ci
Browse files Browse the repository at this point in the history
Use GitHub actions for continuous integration (CI)
  • Loading branch information
WyriHaximus authored Jul 8, 2021
2 parents 834c1f0 + a767084 commit dd9d741
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .env.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GITHUB_TOKEN=""
DEPLOY_REPO="reactphp/reactphp.github.io"
DEPLOY_TARGET_BRANCH="master"
DEPLOY_URL=""
DEPLOY_URL="https://reactphp.org"
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy

on:
push:
pull_request:
workflow_dispatch:

jobs:
Deploy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.1
- run: composer install
- run: mkdir ~/.ssh && echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_rsa && chmod 400 ~/.ssh/id_rsa
- run: echo 'GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}"' > .env && cat .env.dist >> .env
- run: git config --global user.name "GitHub Actions" && git config --global user.email "[email protected]"
- run: bin/build
- run: bin/build --deploy --no-component-update
if: ${{ github.ref == 'refs/heads/main' }}
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

79 changes: 64 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Website
=======
# Website

[![CI status](https://github.com/reactphp/website/workflows/CI/badge.svg)](https://github.com/reactphp/website/actions)

Source code of reactphp.org.

Setup
-----
## Setup

1. Copy `.env.dist` to `.env` and add a
[personal access token](https://github.com/settings/tokens) to the
Expand All @@ -17,20 +17,69 @@ Setup

2. Install dependencies with `$ composer install`.

Auto-Deployment with Travis CI
------------------------------
## Build

Once set up, you can build the website by executing this:

```bash
$ bin/build
```

This script will fetch all project repositories and then rebuild the entire website.
The resulting static website will be built into the `tmp/build` directory.

If you're working on the website source code, you may want to skip fetching all
components on every build like this:

```bash
$ bin/build --no-component-update
```

If you're working on the website CSS or Javascript code, you will have to
rebuild the static assets like this:

```bash
$ npm run-script build
```

> Note that compiled assets are expected to change much less frequently and are
under version control. Run `npm install` to install and later commit any changes
in `static-files/assets/`.

## Deploy

Once built (see previous chapter), deployment is as simple as hosting the static
website contents of the `tmp/build` directory behind a webserver of your choice.

We use GitHub Pages to deploy this to the live site. This is done by pushing the
contents of the `tmp/build` directory to the repository hosted in
[reactphp/reactphp.github.io](https://github.com/reactphp/reactphp.github.io).

This deployment can be started by executing this:

```bash
$ bin/build --deploy
```

Note that this will publish any changes you've made to your local repository,
including any uncommitted ones. There should usually be no need to do this
manually, see next chapter for auto-deployment.

## Auto-Deployment

The website can be automatically deployed via the GitHub Pages feature.

The website can be automatically deployed via the Travis CI
[GitHub Pages Deployment](https://docs.travis-ci.com/user/deployment/pages/)
feature.
Any time a commit is merged (such as when a PR is merged), GitHub actions will
automatically build and deploy the website. This is done by running the above
deployment script (see previous chapter).

Make sure, the required environment variables are set in the repository settings
on Travis CI: `GITHUB_TOKEN`
([a personal access token](https://docs.travis-ci.com/user/deployment/pages/#Setting-the-GitHub-token)),
`DEPLOY_REPO`, `DEPLOY_TARGET_BRANCH` and `DEPLOY_FQDN`.
> Repository setup:
> We're using a SSH deploy key for pushing to this target repository.
> Make sure the required `DEPLOY_KEY` secret is set in the repository settings on GitHub.
> See [action documentation](https://github.com/JamesIves/github-pages-deploy-action#using-an-ssh-deploy-key-)
> for more details.
License
-------
## License

Released under the [MIT](LICENSE) license.

Expand Down
1 change: 0 additions & 1 deletion bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ call_user_func(include $configFile, $container);
function run($command, $cwd = null)
{
$process = new Symfony\Component\Process\Process($command, $cwd);
$process->setTty(true);

$process->mustRun(function ($type, $buffer) {
echo $buffer;
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@
"elvanto/litemoji": "^1.0",
"zendframework/zend-feed": "^2.10",
"igorw/retry": "^1.0@dev"
},
"config": {
"platform": {
"php": "7.1.99"
}
}
}
132 changes: 114 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions config/berti.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
// Ignore missing .env
}

// use UTC timezone for all dates on website (release dates in changelogs)
date_default_timezone_set('UTC');

return function (Pimple\Container $container) {
$container['markdown.cache'] = function () {
return new Symfony\Component\Cache\Adapter\FilesystemAdapter(
Expand Down
Loading

0 comments on commit dd9d741

Please sign in to comment.