-
Notifications
You must be signed in to change notification settings - Fork 7
41 lines (34 loc) · 1.35 KB
/
bakery.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
name: bakery
on:
push:
branches: [ master ]
paths:
- 'bakery/**'
- .github/workflows/bakery.yaml
env:
IMAGE_NAME: bakery
jobs:
build-and-publish-latest:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' # Running this job only for master branch
steps:
- uses: actions/checkout@v2
- name: Build image
run: |
CHEFDK_VERSION=$(cat ${IMAGE_NAME}/chefdk.version)
PACKER_VERSION=$(cat ${IMAGE_NAME}/packer.version)
docker build --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" --build-arg CHEFDK_VERSION=${CHEFDK_VERSION} --build-arg PACKER_VERSION=${PACKER_VERSION} ${IMAGE_NAME}/
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
CHEFDK_VERSION=$(cat ${IMAGE_NAME}/chefdk.version)
PACKER_VERSION=$(cat ${IMAGE_NAME}/packer.version)
IMAGE_TAG=c${CHEFDK_VERSION}-p${PACKER_VERSION}
echo "pushing ${IMAGE_NAME} version ${IMAGE_TAG}"
docker tag $IMAGE_NAME $IMAGE_ID:latest
docker tag $IMAGE_NAME $IMAGE_ID:${IMAGE_TAG}
docker push $IMAGE_ID:latest
docker push $IMAGE_ID:${IMAGE_TAG}