forked from RocketPuppy/git_immersion
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (63 loc) · 2.29 KB
/
build-and-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
name: Build and Deploy
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # need the gh-pages branch
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Package Labs and Zip
run: |
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
bundle exec rake repackage
- if: github.ref_name == 'main'
name: Deploy Main
run: |
MSG=$(git log --pretty="%h" -n1)
git checkout gh-pages
cp --recursive --force git_tutorial/html/* .
cp --force dist/git_tutorial.zip .
git add --all .
git config user.name "github-actions"
git config user.email "[email protected]"
git commit -m "Updated gh-pages to $MSG"
git push
- if: github.ref_name != 'main'
name: Deploy Branch
env:
BRANCH: ${{ github.head_ref }}
run: |
MSG=$(git log --pretty="%h" -n1)
git checkout gh-pages
mkdir -p $BRANCH/
cp --recursive --force git_tutorial/html/* $BRANCH/
cp --force dist/git_tutorial.zip $BRANCH/
git add --all $BRANCH
git config user.name "github-actions"
git config user.email "[email protected]"
git commit -m "Updated gh-pages $BRANCH branch to $MSG"
git push