Merge pull request #1088 from ndw/iss-1083 #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-specs | |
on: push | |
jobs: | |
check_branch: | |
runs-on: ubuntu-latest | |
outputs: | |
branch: ${{ steps.check_step.outputs.branch }} | |
reponame: ${{ steps.check_step.outputs.reponame }} | |
tag: ${{ steps.check_step.outputs.tag }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get branch name, etc. | |
id: check_step | |
run: | | |
raw=${{ github.repository }} | |
reponame=${raw##*/} | |
echo "reponame=$reponame" >> $GITHUB_STATE | |
raw=$(git branch -r --contains ${{ github.ref }}) | |
branch=${raw##*/} | |
echo "branch=$branch" >> $GITHUB_STATE | |
tag="" | |
if [ ${{ github.ref_type }} = "tag" ]; then | |
tag=${{ github.ref_name }} | |
echo "Running in $reponame on $branch for $tag" | |
else | |
echo "Running in $reponame on $branch" | |
fi | |
echo "tag=$tag" >> $GITHUB_STATE | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
needs: check_branch | |
env: | |
HAVE_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN != '' }} | |
DIFFURI: ${{ secrets.DIFFURI }} | |
DIFFPW: ${{ secrets.DIFFPW }} | |
CIWORKFLOW: yes | |
CI_SHA1: ${{ github.sha }} | |
CI_BUILD_NUM: ${{ github.run_number }} | |
CI_PROJECT_USERNAME: ${{ github.repository_owner }} | |
CI_PROJECT_REPONAME: ${{ needs.check_branch.outputs.reponame }} | |
CI_BRANCH: ${{ needs.check_branch.outputs.branch }} | |
CI_TAG: ${{ needs.check_branch.outputs.tag }} | |
steps: | |
# We’re going to be updating the gh-pages branch, but that | |
# happens from two repositories. We must preserve what we | |
# don’t change by getting the current version | |
- name: Checkout current gh-pages | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: build/dist | |
- name: Preserve the relevant current gh-pages | |
run: | | |
mkdir /tmp/save-gh-pages | |
if [ -d build/dist/${{ github.ref_name }}/head ]; then | |
rsync -ar build/dist/${{ github.ref_name }}/head/ /tmp/save-gh-pages/ | |
fi | |
- name: Checkout this repository | |
uses: actions/checkout@v4 | |
- name: Restore the relevant gh-pages | |
run: | | |
mkdir -p build/dist | |
rsync -ar /tmp/save-gh-pages/ build/dist/ | |
rm -rf /tmp/save-gh-pages | |
- name: Setup DeltaXML | |
run: | | |
echo Setup DeltaXML | |
if [[ -z "${DIFFURI}" ]]; then | |
echo "DeltaXML unavailable" | |
else | |
curl -s $DIFFURI | openssl enc -aes-256-cbc -salt -pbkdf2 -d -k $DIFFPW | tar zxf - | |
fi | |
- name: Build the specifications | |
run: | | |
./gradlew | |
- name: Cleanup DeltaXML | |
run: rm -rf deltaxml | |
- name: Deploy to gh-pages | |
if: ${{ env.HAVE_ACCESS_TOKEN == 'true' }} | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: build/dist | |
token: ${{ secrets.ACCESS_TOKEN }} | |
branch: gh-pages | |
target-folder: /${{ github.ref_name }}/head |