|
1 | 1 | #!/bin/bash |
2 | 2 | set -e |
3 | 3 |
|
| 4 | +GHA_BRANCH=${GITHUB_REF#refs/heads/} |
| 5 | + |
4 | 6 | # Deploy built docs to this branch |
5 | 7 | TARGET_BRANCH=gh-pages |
6 | 8 |
|
|
11 | 13 |
|
12 | 14 | REPO=$(git config remote.origin.url) |
13 | 15 |
|
14 | | -if [ -n "$TRAVIS_BUILD_ID" ]; then |
15 | | - # When running on Travis we need to use SSH to deploy to GitHub |
16 | | - # |
17 | | - # The following converts the repo URL to an SSH location, |
18 | | - # decrypts the SSH key and sets up the Git config with |
19 | | - # the correct user name and email (globally as this is a |
20 | | - # temporary travis environment) |
21 | | - # |
22 | | - # Set the following environment variables in the travis configuration (.travis.yml) |
23 | | - # |
24 | | - # DEPLOY_BRANCH - The only branch that Travis should deploy from |
25 | | - # ENCRYPTION_LABEL - The label assigned when encrypting the SSH key using travis encrypt-file |
26 | | - # GIT_NAME - The Git user name |
27 | | - # GIT_EMAIL - The Git user email |
28 | | - # |
29 | | - echo DEPLOY_BRANCH: $DEPLOY_BRANCH |
30 | | - echo ENCRYPTION_LABEL: $ENCRYPTION_LABEL |
31 | | - echo GIT_NAME: $GIT_NAME |
32 | | - echo GIT_EMAIL: $GIT_EMAIL |
33 | | - if [ "$TRAVIS_BRANCH" != "$DEPLOY_BRANCH" ]; then |
34 | | - echo "Travis should only deploy from the DEPLOY_BRANCH ($DEPLOY_BRANCH) branch" |
| 16 | +echo DEPLOY_BRANCH: $DEPLOY_BRANCH |
| 17 | +echo GIT_NAME: $GIT_NAME |
| 18 | +echo GIT_EMAIL: $GIT_EMAIL |
| 19 | +echo GHA_BRANCH: $GHA_BRANCH |
| 20 | +if [ "$GHA_BRANCH" != "$DEPLOY_BRANCH" ]; then |
| 21 | + echo "Actions should only deploy from the DEPLOY_BRANCH ($DEPLOY_BRANCH) branch" |
35 | 22 | exit 0 |
36 | | - else |
37 | | - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then |
38 | | - echo "Travis should not deploy from pull requests" |
39 | | - exit 0 |
40 | | - else |
41 | | - # switch both git and https protocols as we don't know which travis |
42 | | - # is using today (it changed!) |
43 | | - REPO=${REPO/git:\/\/github.com\//git@github.com:} |
44 | | - REPO=${REPO/https:\/\/github.com\//git@github.com:} |
45 | | - |
46 | | - chmod 600 $SSH_KEY |
47 | | - eval `ssh-agent -s` |
48 | | - ssh-add $SSH_KEY |
49 | | - git config --global user.name "$GIT_NAME" |
50 | | - git config --global user.email "$GIT_EMAIL" |
51 | | - fi |
52 | | - fi |
53 | 23 | fi |
| 24 | + |
| 25 | +REPO="https://RobinThrift:${GH_TOKEN}@github.com/HannoverJS/website.git" |
| 26 | + |
| 27 | +git config --global user.name "$GIT_NAME" |
| 28 | +git config --global user.email "$GIT_EMAIL" |
54 | 29 |
|
55 | 30 | REPO_NAME=$(basename $REPO) |
56 | 31 | TARGET_DIR=$(mktemp -d /tmp/$REPO_NAME.XXXX) |
57 | 32 | REV=$(git rev-parse HEAD) |
58 | 33 | git clone --branch ${TARGET_BRANCH} ${REPO} ${TARGET_DIR} |
59 | | -rsync -rt --delete --exclude=".git" --exclude=".travis.yml" $SOURCE_DIR/ $TARGET_DIR/ |
| 34 | +rsync -rt --delete --exclude=".git" --exclude=".github" $SOURCE_DIR/ $TARGET_DIR/ |
60 | 35 | cd $TARGET_DIR |
61 | 36 | echo "hannoverjs.de" > CNAME |
62 | 37 | git add -A . |
63 | 38 | git commit --allow-empty -m "auto-build: build from $REV at $(date)" |
64 | | -git push $REPO $TARGET_BRANCH |
| 39 | +git remote add gh $REPO |
| 40 | +git push gh $TARGET_BRANCH |
65 | 41 |
|
66 | | -git config --global user.name "$GIT_NAME" |
67 | | -git config --global user.email "$GIT_EMAIL" |
0 commit comments