Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add actions to build PRs and develop, cleanup closed PRs. #1172

Merged
merged 25 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
44874b4
Add actions to build PRs and develop, cleanup closed PRs.
adamsilverstein Feb 25, 2020
2907354
adjust build command for new dynamic zip file naming
adamsilverstein Feb 25, 2020
ba06fd3
Merge branch 'develop' into feature/add-repo-actions
felixarntz Feb 28, 2020
5d2f2de
use npm command for zip build
adamsilverstein Feb 28, 2020
4a43389
Merge branch 'feature/add-repo-actions' of github.com:google/site-kit…
adamsilverstein Feb 28, 2020
fcd7b1c
Use node version from .nvmrc
adamsilverstein Feb 28, 2020
caed4bc
Remove gulp install.
adamsilverstein Feb 28, 2020
6f0fdf2
Assign $1 to GIT_REF.
adamsilverstein Feb 28, 2020
b3612da
Move GIT_REF to env.
adamsilverstein Feb 28, 2020
36f4963
Base tmp dir name on git ref.
adamsilverstein Feb 28, 2020
93a438c
Clean up copy command.
adamsilverstein Feb 28, 2020
72c853e
Remove action: pass ref to bash script via env.
adamsilverstein Feb 28, 2020
fec6cca
Clean up copy command.
adamsilverstein Feb 28, 2020
30ed8e4
Correct git commands.
adamsilverstein Feb 28, 2020
64bbc86
Clean up mv commands.
adamsilverstein Feb 28, 2020
d048a32
Copy built files into place.
adamsilverstein Feb 28, 2020
d1073c8
Clean dist when performing a dev build.
aaemnnosttv Feb 28, 2020
0545345
Shallow clone wiki repo for efficiency.
aaemnnosttv Feb 28, 2020
0cee859
Deploy to wiki in dedicated job using artifacts.
aaemnnosttv Feb 29, 2020
0d5da4a
Add release zip.
aaemnnosttv Feb 29, 2020
b4cac9e
Set git commit info and test push.
aaemnnosttv Feb 29, 2020
5f2a962
Fix env syntax.
aaemnnosttv Feb 29, 2020
1c22b82
Push zips to wiki.
aaemnnosttv Feb 29, 2020
1e24d8a
Remove old release script.
aaemnnosttv Feb 29, 2020
1051d69
Refactor remove-pr with checkout action.
aaemnnosttv Feb 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/release-to-wiki.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git"

tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
aaemnnosttv marked this conversation as resolved.
Show resolved Hide resolved
(
cd "$tmp_dir" || exit 1
git init
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git pull "$GIT_REPOSITORY_URL"
aaemnnosttv marked this conversation as resolved.
Show resolved Hide resolved
)

mkdir -p "$tmp_dir/$1"
aaemnnosttv marked this conversation as resolved.
Show resolved Hide resolved
for file in $(find $1 -maxdepth 1 -type f -name '*' -execdir basename '{}' ';'); do
cp "$1/$file" "$tmp_dir/$1"
done
aaemnnosttv marked this conversation as resolved.
Show resolved Hide resolved

echo "Publishing build files for $1"
(
cd "$tmp_dir" || exit 1
git add .
git commit -m "Build and publish $1"
git push --set-upstream "$GIT_REPOSITORY_URL" master
)

rm -rf "$tmp_dir"
exit 0
25 changes: 25 additions & 0 deletions .github/remove-from-wiki.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git"

echo "Checking out wiki repository"
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
(
cd "$tmp_dir" || exit 1
git init
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git pull "$GIT_REPOSITORY_URL"
)

rm -Rf "$tmp_dir/$1"

echo "Removing build files from $1"
(
cd "$tmp_dir" || exit 1
git commit -m "$WIKI_COMMIT_MESSAGE"
git push --set-upstream "$GIT_REPOSITORY_URL" master
)

rm -rf "$tmp_dir"
exit 0
60 changes: 60 additions & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build-pr

on:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we build the PR on any tags/and on master it would save us (usually @felixarntz) having to build the production ZIP by hand on a Mac. Having the CI generate our builds instead of us doing it manually is way nicer, so I filed #1196 to chat about that and extend this later 😄

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

push:
branches:
- develop
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs on pushes to develop, but doesn't remove the file. Will the upload overwrite this one based on the ref being the branch name (develop) over the commit hash?

If so that seems fine, but just wanna make sure this isn't going to spawn a lot of ZIP files 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated zip files are renamed as google-site-kit.zip and google-site-kit-dev.zip so yes 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: the github.ref in this case is refs/heads/develop (so that is where the zips wind up being stored)

pull_request:
adamsilverstein marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer Install
uses: php-actions/composer@v1
with:
args: install
- name: Setup Node.js 10
uses: actions/setup-node@v1
with:
node-version: '10.x'
aaemnnosttv marked this conversation as resolved.
Show resolved Hide resolved
- name: Cache Node - npm
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-cache-
- name: npm/Gulp Install
run: |
npm install
npm install gulp-cli -g
aaemnnosttv marked this conversation as resolved.
Show resolved Hide resolved
- name: Build develop version
run: |
npm run build:dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really scope of this PR, but the scripts in package.json are a bit inconsistent between how they work for production vs development. E.g. build:dev includes a call to build:static while build:production and build:test don't.

I'll open a small separate issue with this.

ZIP=`gulp release | grep Creating | cut -c10-`
mv "$ZIP" google-site-kit-dev.zip
- name: Build release version
run: |
npm run build
ZIP=`gulp release | grep Creating | cut -c10-`
mv "$ZIP" google-site-kit.zip
aaemnnosttv marked this conversation as resolved.
Show resolved Hide resolved
- name: Deploy build files to wiki
run: |
mkdir -p ${{ github.ref }}
mv google-site-kit.zip ${{ github.ref }}
mv google-site-kit-dev.zip ${{ github.ref }}
bash .github/release-to-wiki.sh ${{ github.ref }}
env:
GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/remove-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: remove-pr

on:
pull_request:
types: [closed]
jobs:
remove-pr:
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
run: |
bash .github/remove-from-wiki.sh ${{ github.ref }}
env:
GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}