-
Notifications
You must be signed in to change notification settings - Fork 150
53 lines (52 loc) · 1.74 KB
/
build-and-deploy.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
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@v2
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