This repository has been archived by the owner. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 correct action syntax and add media
- Loading branch information
1 parent
81e0fdc
commit 120eff5
Showing
6 changed files
with
1,429 additions
and
58 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
FROM ruby:$INPUT_RUBY_VERSION-alpine | ||
FROM ruby:2.7.1-alpine | ||
|
||
# Set default locale for the environment | ||
ENV LC_ALL C.UTF-8 | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US.UTF-8 | ||
|
||
RUN apt-get update; \ | ||
apt-get install -y --no-install-recommends build-base git nodejs yarn | ||
RUN apk --no-cache add build-base git; \ | ||
apk add --repository http://dl-cdn.alpinelinux.org/alpine/edge/main/ --no-cache \ | ||
nodejs \ | ||
nodejs-npm \ | ||
yarn | ||
|
||
# Copies your code file from your action repository to the filesystem path `/` of the container | ||
# This is our entrypoint to our custom scripts | ||
# more about that in a sec | ||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
# Code file to execute when the docker container starts up (`entrypoint.sh`) | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
# Use the entrypoint.sh file as the container entrypoint | ||
# when Github executes our Docker container | ||
ENTRYPOINT ["sh", "/entrypoint.sh"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
# bridgetown-gh-pages-action | ||
<div align="center"> | ||
<img alt="Banner" width="100%" src="media/banner.png" /> | ||
<h1>bridgetown-gh-pages-action</h1> | ||
<p>A GitHub Action for building and deploying a <a href="https://www.bridgetownrb.com" target="_blank">Bridgetown site</a> to GitHub Pages.</p> | ||
</div> | ||
|
||
> A GitHub Action for building and deploying a Bridgetown site to GitHub Pages. | ||
## Getting Started | ||
|
||
## Inputs | ||
This is intended to be an out-of-the-box solution for deploying your [Bridgetown](https://www.bridgetownrb.com) to [GitHub Pages](https://pages.github.com/). | ||
|
||
| Name | Type | Required? | Default | Description | | ||
| -------------- | ------ | --------- | -------------------------- | ------------------------------------------------------------------------ | | ||
| github_token | String | true | | Token for the repo. Can be passed in using \${{ secrets.GITHUB_TOKEN }}. | | ||
| repository | String | false | `${{ github.repository }}` | The GitHub repository to push the built site to. | | ||
| github_actor | String | false | `${{ github.actor }}` | Name of the deploy actor. | | ||
| site_location | String | false | `.` | Location of the Bridgetown project within your repo. | | ||
| build_location | String | false | `./output` | Location of your Bridgetown generated site. | | ||
| default_branch | String | false | `main` | The name of your default branch. | | ||
| deploy_branch | String | false | `gh-pages` | Branch name to push the site to. | | ||
| ruby_version | String | false | `2.7.1` | The Ruby version you want to use to build the site. | | ||
| commit_message | String | false | `chore: deploy site` | The commit message that will be used when deploying. | | ||
```yml | ||
- name: Build & Deploy to GitHub Pages | ||
uses: andrewmcodes/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
``` | ||
**:rotating_light: IMPORTANT** Due to the way GitHub Actions work, you cannot pass in a Ruby version to the Docker container that gets built (or at least I can't find a way). **Due to this, this action will build your site with Ruby 2.7.1**. If you cannot upgrade your Ruby version for some reason, I suggest forking this action and adding the Ruby version you need in the Dockerfile, or using a [manual solution](#manual-solution). | ||
## Usage | ||
|
@@ -34,9 +35,9 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build & Deploy to GitHub Pages | ||
uses: andrewmcodes/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
uses: andrewmcodes/[email protected] | ||
``` | ||
### Advanced | ||
|
@@ -55,16 +56,88 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build & Deploy to GitHub Pages | ||
uses: andrewmcodes/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
repository: andrewmcodes/bridgetown-gh-pages-action | ||
github_actor: octokit | ||
site_location: "./site" | ||
build_location: "./site/output" | ||
deploy_branch: "deploy" | ||
ruby_version: "2.7.0" | ||
commit_message: "Release the site" | ||
uses: andrewmcodes/[email protected] | ||
``` | ||
## Inputs | ||
| Name | Type | Required? | Default | Description | | ||
| -------------- | ------ | --------- | -------------------------- | ------------------------------------------------------------------------ | | ||
| github_token | String | true | | Token for the repo. Can be passed in using \${{ secrets.GITHUB_TOKEN }}. | | ||
| repository | String | false | `${{ github.repository }}` | The GitHub repository to push the built site to. | | ||
| github_actor | String | false | `${{ github.actor }}` | Name of the deploy actor. | | ||
| site_location | String | false | `.` | Location of the Bridgetown project within your repo. | | ||
| build_location | String | false | `./output` | Location of your Bridgetown generated site. | | ||
| default_branch | String | false | `main` | The name of your default branch. | | ||
| deploy_branch | String | false | `gh-pages` | Branch name to push the site to. | | ||
| commit_message | String | false | `chore: deploy site` | The commit message that will be used when deploying. | | ||
|
||
## Manual Solution | ||
|
||
If you cannot use this action due to version constraints or other issues, you can do this manually with something like: | ||
|
||
```yaml | ||
name: Deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
name: Deploy to GitHub Pages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: "13.x" | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- uses: actions/cache@v1 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Set up Ruby 2.7 | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.7.1 | ||
- name: Cache gems | ||
uses: actions/cache@v1 | ||
with: | ||
path: vendor/bundle | ||
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-gems- | ||
- name: Install Dependencies | ||
run: | | ||
bundle config path vendor/bundle | ||
bundle install --jobs 4 --retry 3 | ||
yarn install | ||
- name: Build site for deployment | ||
run: yarn deploy | ||
- name: Deploy to GitHub Pages | ||
if: success() | ||
uses: crazy-max/ghaction-github-pages@v2 | ||
with: | ||
target_branch: gh-pages | ||
build_dir: output | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
``` | ||
|
||
## Changelog | ||
|
@@ -73,12 +146,16 @@ jobs: | |
|
||
## Contributing | ||
|
||
[Contributing Guide][contributing] | ||
Contributions, issues and feature requests are welcome! | ||
|
||
Please make sure you read the [Contributing Guide][contributing] before getting started! | ||
|
||
## Code of Conduct | ||
|
||
[Code of Conduct][coc] | ||
|
||
## License | ||
|
||
[MIT][license] | ||
Copyright © 2020 [Andrew Mason](https://github.com/andrewmcodes). | ||
<br /> | ||
This project is [MIT](https://github.com/andrewmcodes/bridgetown-gh-pages-action/blob/main/LICENSE) licensed. |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,47 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
|
||
# Exit immediately if a pipeline returns a non-zero status. | ||
set -e | ||
|
||
ruby -v | ||
REMOTE_REPO="https://${INPUT_GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@github.com/${INPUT_REPOSITORY}.git" | ||
git clone "$REMOTE_REPO" repo | ||
cd repo | ||
|
||
echo "== Installing Dependencies ==" | ||
cd ${INPUT_SITE_LOCATION} | ||
gem install bundler | ||
if [ "${INPUT_SITE_LOCATION}" != "." ]; then | ||
cd "${INPUT_SITE_LOCATION}" | ||
fi | ||
|
||
printf "\nInstalling Ruby Dependencies..." | ||
bundle config path vendor/bundle | ||
bundle install --jobs 4 --retry 3 | ||
yarn install | ||
bundle install --jobs 4 --retry 3 --quiet | ||
|
||
printf "\nInstalling Node Dependencies..." | ||
yarn install --silent | ||
|
||
echo "\n== Running Production Build ==\n" | ||
NODE_ENV=production yarn webpack-build && yarn build | ||
printf "\n\nRunning Production Build...\n" | ||
BRIDGETOWN_ENV=production NODE_ENV=production yarn webpack-build && yarn build | ||
|
||
echo "\n== Committing Changes ==\n" | ||
cd ${INPUT_BUILD_LOCATION} | ||
remote_repo="https://${INPUT_GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@github.com/${INPUT_REPOSITORY}.git" && \ | ||
deploy_branch=${INPUT_DEPLOY_BRANCH} && \ | ||
default_branch=${INPUT_DEFAULT_BRANCH} | ||
printf "\nCommitting Changes...\n" | ||
cd "${INPUT_BUILD_LOCATION}" | ||
git init | ||
git config user.name "${INPUT_GITHUB_ACTOR}" | ||
git config user.email "${INPUT_GITHUB_ACTOR}@users.noreply.github.com" | ||
git add . | ||
|
||
echo -n "Files to Commit:" | ||
printf "Files to Commit...\n" | ||
ls -l | wc -l | ||
echo "Committing files..." | ||
git commit -m "${INPUT_COMMIT_MESSAGE}" > /dev/null 2>&1 | ||
|
||
echo "\n== Deploying ==\n" | ||
echo "Pushing... to $remote_repo $default_branch:$deploy_branch" | ||
git push --force $remote_repo $default_branch:$deploy_branch > /dev/null 2>&1 | ||
printf "\nCommitting files...\n" | ||
git commit -m "${INPUT_COMMIT_MESSAGE}" >/dev/null 2>&1 | ||
|
||
echo "Pushing... to $REMOTE_REPO HEAD:$INPUT_DEPLOY_BRANCH" | ||
git push --force "$REMOTE_REPO" HEAD:"$INPUT_DEPLOY_BRANCH" | ||
|
||
printf "\nDeployed!\n" | ||
|
||
echo "\n== Cleanup ==\n" | ||
printf "\nCleanup...\n" | ||
rm -fr .git | ||
cd - | ||
cd .. | ||
rm -fr repo | ||
|
||
echo "\n== Done ==\n" | ||
printf "\nDone..." |
Oops, something went wrong.