57 lines (57 loc) · 2.03 KB
/
ci.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
name: CI
on:
## Events from external actor, or from code pushed (includes tags pushed)
push:
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
env:
CACHE_REGISTRY: ghcr.io
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Define custom env variables
run: |
echo "CACHE_REGISTRY_PREFIX=${CACHE_REGISTRY}/asciidoctor" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
registry: ${{ env.CACHE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: |
make build
- name: Deploy Cache
# Only upstream has the cache registry credential as PRs cannot be trusted
if: github.event_name != 'pull_request'
run: |
make docker-cache
- 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: Set up Git user for deploy and custom README
run: |
git config --local user.name "${GITHUB_ACTOR}"
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Generate README
run: make README
- name: Deploy
if: github.event_name != 'pull_request'
env:
DOCKERHUB_SOURCE_TOKEN: ${{ secrets.DOCKERHUB_SOURCE_TOKEN }}
DOCKERHUB_TRIGGER_TOKEN: ${{ secrets.DOCKERHUB_TRIGGER_TOKEN }}
DOCKERHUB_FINAL_IMAGE_NAME: "${GITHUB_ACTOR}"
run: make deploy-README deploy