Skip to content

Build and Deploy

Build and Deploy #628

name: "Build and Deploy"
on:
## Events from external actor, or from code pushed (includes tags pushed)
push:
branches:
- main
- 'refs/tags/*'
tags:
- '*'
pull_request:
## Events from the GitHub UI (as when publishing a release)
# When a release is "released" (draft or released published, no pre-release) - https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#release
release:
types: [released]
# When a tag or branch is created in the GitHub UI
create:
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.9.1
- name: Build
run: |
make build
- name: Install dependencies for Tests
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends bats
- name: Test
run: make test
- name: Generate README
run: make README
#### Deployment Zone: only on main branch
- name: Login to Docker Hub for Deployment
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Deploy
if: github.event_name != 'pull_request'
run: |
export IMAGE_VERSION="$(echo ${GITHUB_REF#refs/tags/} | grep -v 'refs/heads')"
export IMAGE_NAME="asciidoctor/docker-asciidoctor"
git config --local user.name "${GITHUB_ACTOR}"
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
make deploy-README deploy