-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (88 loc) · 4.35 KB
/
deploy-docs-for-v2-release.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Build and deploy documentation for 2.x
run-name: Deploy ${{ github.event.inputs.version }} site artifact.
on:
workflow_call:
inputs:
sha:
required: true
type: string
ref:
required: true
type: string
version:
required: true
type: string
jobs:
release:
name: Create Release
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
repository: az-digital/digital.arizona.edu
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
- name: Build variables
run: |
stem='arizona-bootstrap'
clonedir='arizona-bootstrap'
echo "AZ_REVIEW_BASEURL=/${stem}" >> ${GITHUB_ENV}
echo "AZ_SITE_HOST=https://digital.arizona.edu" >> ${GITHUB_ENV}
echo "AZ_BOOTSTRAP_CLONE_DIR=${clonedir}" >> ${GITHUB_ENV}
echo "AZ_BOOTSTRAP_CLONE_FULL_PATH=${GITHUB_WORKSPACE}/${clonedir}" >> ${GITHUB_ENV}
echo "AZ_BOOTSTRAP_DOCKERFILE_PATH=${clonedir}/Dockerfile" >> ${GITHUB_ENV}
echo "AZ_BOOTSTRAP_PACKAGE_JSON_PATH=${clonedir}/package.json" >> ${GITHUB_ENV}
echo "AZ_BOOTSTRAP_PACKAGE_LOCK_PATH=${clonedir}/package-lock.json" >> ${GITHUB_ENV}
echo "AZ_BOOTSTRAP_SCRIPTS_PATH=${clonedir}/scripts/*" >> ${GITHUB_ENV}
- name: Get new updates from arizona-bootstrap
uses: actions/checkout@v3
with:
repository: az-digital/arizona-bootstrap
path: ${{ env.AZ_BOOTSTRAP_CLONE_DIR }}
ref: ${{ inputs.sha }}
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
- name: Set variables for Docker images
run: |
oldhash=${{ hashFiles(env.AZ_BOOTSTRAP_DOCKERFILE_PATH, env.AZ_BOOTSTRAP_PACKAGE_JSON_PATH, env.AZ_BOOTSTRAP_PACKAGE_LOCK_PATH, env.AZ_BOOTSTRAP_SCRIPTS_PATH) }}
registry='ghcr.io'
imageprefix="${registry}/arizona-bootstrap/"
imagename='az-nodejs-ephemeral'
imagestem="${imageprefix}${imagename}:"
echo "AZ_IMAGE_STEM=${imagestem}" >> ${GITHUB_ENV}
echo "AZ_OLD_HASH=${oldhash}" >> ${GITHUB_ENV}
echo "AZ_DOCKER_REGISTRY=${registry}" >> ${GITHUB_ENV}
echo "AZ_EPHEMERAL_IMAGE=${imagestem}${oldhash}" >> ${GITHUB_ENV}
echo "AZ_BOOTSTRAP_SOURCE_DIR=arizona-bootstrap-source" >> ${GITHUB_ENV}
echo "AZ_BOOTSTRAP_FROZEN_DIR=/azbuild/arizona-bootstrap" >> ${GITHUB_ENV}
- name: Docker authentication
run: |
docker login "$AZ_DOCKER_REGISTRY" -u "$GITHUB_ACTOR" -p ${{ secrets.GITHUB_TOKEN }}
- name: Search for Docker image
id: dockerpull
continue-on-error: true
run: |
docker pull "$AZ_EPHEMERAL_IMAGE"
- name: Conditionally rebuild the Docker image
if: ${{ steps.dockerpull.outcome == 'failure' }}
run: |
workingtitle=$(docker build -q "$AZ_BOOTSTRAP_CLONE_FULL_PATH")
tempname="old${AZ_OLD_HASH}"
docker run --name "$tempname" "$workingtitle" true
docker cp -a "${tempname}:${AZ_BOOTSTRAP_FROZEN_DIR}/." "$AZ_BOOTSTRAP_CLONE_FULL_PATH"
docker rm "$tempname"
lockhash=${{ hashFiles(env.AZ_BOOTSTRAP_DOCKERFILE_PATH, env.AZ_BOOTSTRAP_PACKAGE_JSON_PATH, env.AZ_BOOTSTRAP_PACKAGE_LOCK_PATH, env.AZ_BOOTSTRAP_SCRIPTS_PATH) }}
ephemeral="${AZ_IMAGE_STEM}${lockhash}"
docker tag "$workingtitle" "$ephemeral"
echo "AZ_EPHEMERAL_IMAGE=${ephemeral}" >> ${GITHUB_ENV}
- name: Build and deploy documentation site artifact
run: |
sudo touch "${AZ_BOOTSTRAP_CLONE_DIR}/config.yml"
sudo find "$AZ_BOOTSTRAP_CLONE_DIR" -path "${AZ_BOOTSTRAP_CLONE_DIR}/.git" -prune -o -exec chown 1000:1000 {} \;
sudo chown 1000:1000 "$AZ_BOOTSTRAP_CLONE_DIR"
docker run --rm -e "AZ_SITE_BASE_URL=${AZ_REVIEW_BASEURL}" -e "AZ_SITE_HOST=${AZ_SITE_HOST}" -v "$AZ_BOOTSTRAP_CLONE_FULL_PATH":"/${AZ_BOOTSTRAP_SOURCE_DIR}" "$AZ_EPHEMERAL_IMAGE" expose-review-site
rsync --recursive --delete "${AZ_BOOTSTRAP_CLONE_DIR}/_site/" "docs${AZ_REVIEW_BASEURL}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git add docs${AZ_REVIEW_BASEURL}
git commit -m "Arizona Bootstrap documentation updates for ${{ inputs.version }}"
git push