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 all 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
83 changes: 83 additions & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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: Read .nvmrc
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a nice touch. I usually just specify the node version in the action, but I like that! 👍

run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvm
- name: Setup Node.js (.nvmrc)
uses: actions/setup-node@v1
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
- 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 install
run: |
npm install
- name: Create destination directory
run: mkdir -p ${{ github.ref }}
- name: Build develop version
run: |
npm run dev-zip
mv *.zip ${{ github.ref }}/google-site-kit-dev.zip
- name: Build release version
run: |
npm run release-zip
mv *.zip ${{ github.ref }}/google-site-kit.zip
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: zip-files
path: ${{ github.ref }}

deploy-to-wiki:
runs-on: ubuntu-latest
needs: build-pr
steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.repository }}.wiki
- name: Download artifacts
uses: actions/download-artifact@v1
with:
name: zip-files
path: ${{ github.ref }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Love how this works!

- name: Commit updates
run: |
git add .
git status
git commit -m "Build and publish ${{ github.ref }}"
git push origin master
env:
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.actor }}
24 changes: 24 additions & 0 deletions .github/workflows/remove-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: remove-pr

on:
pull_request:
types: [closed]
jobs:
remove-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.repository }}.wiki
- name: Prune PR files
run: |
rm -rf ${{ github.ref }}
git add .
git status
git commit -m "Prune ${{ github.ref }}"
git push origin master
env:
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.actor }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"build": "npm run remove-dist && npm run build:production && npm run build:static",
"build:production": "webpack -p --mode=production",
"build:test": "webpack -p --mode=production --include-tests",
"build:dev": "npm run build:static && webpack --mode=development --debug --devtool cheap-source-map --output-pathinfo",
"build:dev": "npm run remove-dist && npm run build:static && webpack --mode=development --debug --devtool cheap-source-map --output-pathinfo",
"build:static": "gulp svg imagemin",
"dev": "npm run build:dev && npm run build:static",
"dev-zip": "npm run build:dev && gulp release",
aaemnnosttv marked this conversation as resolved.
Show resolved Hide resolved
"watch": "npm run remove-dist && npm run build:static && webpack --watch --mode=development --debug --devtool cheap-module-eval-source-map --output-pathinfo",
"release-zip": "npm run build && gulp release",
"remove-dist": "rm -rf dist/*",
Expand Down