-
Notifications
You must be signed in to change notification settings - Fork 6
123 lines (115 loc) · 3.57 KB
/
bot.yaml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: 'Build & Push: bot'
on:
push:
branches:
- main
paths:
- images/bot/**
- .github/workflows/bot.yaml
pull_request:
paths:
- images/bot/**
- .github/workflows/bot.yaml
jobs:
build:
name: Build & Push
strategy:
matrix:
include:
- tag: comment
packages: ""
- tag: merge
packages: "anaconda-client skopeo"
- tag: update
packages: "git openssh"
runs-on: ubuntu-22.04
env:
IMAGE_NAME: bot
IMAGE_VERSION: '1.3.0'
steps:
- uses: actions/checkout@v2
- name: Build
id: buildah-build
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: >-
${{ matrix.tag }}
${{ matrix.tag }}-${{ env.IMAGE_VERSION }}
context: ./images/${{ env.IMAGE_NAME }}
dockerfiles: |
./images/${{ env.IMAGE_NAME }}/Dockerfile
build-args: |
packages=${{ matrix.packages }}
- name: Test
run: |
image='${{ steps.buildah-build.outputs.image }}'
ids="$(
for tag in ${{ steps.buildah-build.outputs.tags }} ; do
buildah images --quiet --no-trunc "${image}:${tag}"
done
)"
ids="$( printf %s "${ids}" | sort -u )"
for id in ${ids} ; do
podman history "${id}"
buildah bud \
--build-arg=base="${id}" \
--file=Dockerfile.test \
'images/${{ env.IMAGE_NAME }}'
done
buildah rmi --prune || true
#- name: Check Tags
# run: |
# # FIX upstream: Quay.io does not support immutable images currently.
# # => Try to use the REST API to check for duplicate tags.
# respone="$(
# curl -sL \
# 'https://quay.io/api/v1/repository/bioconda/${{ steps.buildah-build.outputs.image }}/image'
# )"
# existing_tags="$(
# printf %s "${respone}" \
# | jq -r '.images[].tags[]'
# )" \
# || {
# printf %s\\n \
# 'Could not get list of image tags.' \
# 'Does the repository exist on Quay.io?' \
# 'Quay.io REST API response was:' \
# "${respone}"
# exit 1
# }
# for tag in ${{ steps.buildah-build.outputs.tags }} ; do
# if [ \! "${tag}" = '${{ matrix.tag }}' ] ; then
# if printf %s "${existing_tags}" | grep -qxF "${tag}" ; then
# printf 'Tag %s already exists!\n' "${tag}"
# exit 1
# fi
# fi
# done
- if: ${{ github.ref == 'refs/heads/main' }}
name: Push
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.buildah-build.outputs.image }}
tags: ${{ steps.buildah-build.outputs.tags }}
registry: ${{ secrets.QUAY_BIOCONDA_REPO }}
username: ${{ secrets.QUAY_BIOCONDA_USERNAME }}
password: ${{ secrets.QUAY_BIOCONDA_TOKEN }}
- if: ${{ github.ref == 'refs/heads/main' }}
name: Test Pushed
run: |
image='${{ steps.buildah-build.outputs.image }}'
ids="$(
for tag in ${{ steps.buildah-build.outputs.tags }} ; do
buildah images --quiet --no-trunc "${image}:${tag}"
done
)"
ids="$( printf %s "${ids}" | sort -u )"
for id in ${ids} ; do
podman history "${id}"
buildah bud \
--build-arg=base="${id}" \
--file=Dockerfile.test \
'images/${{ env.IMAGE_NAME }}'
done
buildah rmi --prune || true