Build and push image #116
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
# | |
# The authors of this file have waived all copyright and | |
# related or neighboring rights to the extent permitted by | |
# law as described by the CC0 1.0 Universal Public Domain | |
# Dedication. You should have received a copy of the full | |
# dedication along with this file, typically as a file | |
# named <CC0-1.0.txt>. If not, it may be available at | |
# <https://creativecommons.org/publicdomain/zero/1.0/>. | |
# | |
name: Build and push image | |
on: | |
push: | |
schedule: | |
- cron: '0 0 * * 0' | |
workflow_dispatch: | |
jobs: | |
build_image: | |
name: Build image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Construct the image tag | |
id: tag | |
run: | | |
tag=`date '+%Y-%m-%d'`-${GITHUB_RUN_ID?} || exit $? | |
echo tag=${tag?} >>${GITHUB_OUTPUT?} || exit $? | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build and push the candidate image | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: quinngrier/adock:${{ steps.tag.outputs.tag }}-rc | |
outputs: | |
tag: ${{ steps.tag.outputs.tag }} | |
test_bpmn: | |
name: Test BPMN | |
needs: build_image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Run the test script | |
run: | | |
bash examples/build.bash bpmn \ | |
quinngrier/adock:${{ needs.build_image.outputs.tag }}-rc \ | |
|| exit $? | |
- name: Upload the artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: examples | |
path: examples*/bpmn/** | |
test_graphviz: | |
name: Test Graphviz | |
needs: build_image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Run the test script | |
run: | | |
bash examples/build.bash graphviz \ | |
quinngrier/adock:${{ needs.build_image.outputs.tag }}-rc \ | |
|| exit $? | |
- name: Upload the artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: examples | |
path: examples*/graphviz/** | |
test_pikchr: | |
name: Test Pikchr | |
needs: build_image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Run the test script | |
run: | | |
bash examples/build.bash pikchr \ | |
quinngrier/adock:${{ needs.build_image.outputs.tag }}-rc \ | |
|| exit $? | |
- name: Upload the artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: examples | |
path: examples*/pikchr/** | |
push_image: | |
if: github.ref == 'refs/heads/master' | |
name: Push image | |
needs: | |
- build_image | |
- test_bpmn | |
- test_graphviz | |
- test_pikchr | |
runs-on: ubuntu-latest | |
steps: | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Pull the candidate image | |
run: | | |
docker pull \ | |
quinngrier/adock:${{ needs.build_image.outputs.tag }}-rc \ | |
|| exit $? | |
- name: Tag the final image | |
run: | | |
docker tag \ | |
quinngrier/adock:${{ needs.build_image.outputs.tag }}-rc \ | |
quinngrier/adock:${{ needs.build_image.outputs.tag }} \ | |
|| exit $? | |
docker tag \ | |
quinngrier/adock:${{ needs.build_image.outputs.tag }}-rc \ | |
quinngrier/adock:latest \ | |
|| exit $? | |
- name: Push the final image | |
run: | | |
docker push \ | |
quinngrier/adock:${{ needs.build_image.outputs.tag }} \ | |
|| exit $? | |
docker push \ | |
quinngrier/adock:latest \ | |
|| exit $? | |
update_examples: | |
if: github.ref == 'refs/heads/master' | |
name: Update examples | |
needs: push_image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Remove the old examples | |
run: | | |
x=`git ls-files` || exit $? | |
case ${x?} in ?*) | |
git rm "*" | |
esac | |
- name: Download the new examples | |
uses: actions/download-artifact@v3 | |
with: | |
name: examples | |
- name: Add the new examples | |
run: git add . | |
- name: Commit the new examples | |
run: | | |
export GIT_AUTHOR_NAME="${GITHUB_ACTOR?}" | |
export GIT_AUTHOR_EMAIL= | |
export GIT_COMMITTER_NAME="${GITHUB_SERVER_URL?}/${GITHUB_REPOSITORY?}/actions/runs/${GITHUB_RUN_ID?}" | |
export GIT_COMMITTER_EMAIL= | |
git commit -m "Update the examples" || exit $? | |
- name: Push the new examples | |
run: git push |