Skip to content

Commit e37461e

Browse files
authored
build on tag (#19)
1 parent 46821df commit e37461e

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/build.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Image
2+
on:
3+
push:
4+
branches: [ main ]
5+
tags: [ '*' ]
6+
7+
jobs:
8+
register:
9+
name: Package, Publish, and Register
10+
runs-on:
11+
- ubuntu-latest
12+
steps:
13+
- id: checkout
14+
uses: actions/checkout@v2
15+
- name: Set tag var
16+
id: tag
17+
shell: bash
18+
run: |
19+
#!/usr/bin/env bash
20+
set -euo pipefail
21+
22+
TYPE=$(echo ${GITHUB_REF} | cut -d'/' -f2)
23+
REF=$(echo ${GITHUB_REF} | cut -d'/' -f3)
24+
SHA7=$(echo ${GITHUB_SHA} | cut -c1-7)
25+
26+
TAG=$REF-${SHA7}
27+
if [ "${TYPE}" == "main" ] && [ "${TYPE}" == "tags" ]; then
28+
TAG=$REF
29+
fi
30+
31+
echo ::set-output name=tag::$TAG
32+
33+
- uses: docker/login-action@v1
34+
with:
35+
registry: docker.io
36+
username: ${{ secrets.DOCKER_USERNAME }}
37+
password: ${{ secrets.DOCKER_TOKEN }}
38+
- id: setup-pack
39+
uses: buildpacks/github-actions/setup-pack@v4.3.1
40+
- id: package
41+
run: |
42+
#!/usr/bin/env bash
43+
set -euo pipefail
44+
45+
NAME=$(echo ${GITHUB_REPOSITORY} | cut -d'/' -f2)
46+
PACKAGE="${REPO}/${NAME}"
47+
TAG=${{ steps.tag.outputs.tag }}
48+
49+
pack build --builder paketobuildpacks/builder:tiny --publish ${PACKAGE}:${TAG}
50+
51+
shell: bash
52+
env:
53+
REPO: docker.io/${{ secrets.DOCKER_USERNAME }}

0 commit comments

Comments
 (0)