Merge pull request #29 from mitchclarkebase2/feature/packer-upgrade #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |