use env vars in image names and tags

This commit is contained in:
meeb 2021-05-27 20:49:48 +10:00
parent 22cebba8ac
commit 72dfe51a46
2 changed files with 19 additions and 14 deletions

View File

@ -46,6 +46,8 @@ jobs:
with: with:
platforms: linux/amd64 platforms: linux/amd64
push: true push: true
tags: ghcr.io/meeb/tubesync:latest tags: ghcr.io/meeb/${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=ghcr.io/meeb/tubesync:latest cache-from: type=registry,ref=ghcr.io/meeb/${{ env.IMAGE_NAME }}:latest
cache-to: type=inline cache-to: type=inline
build-args: |
IMAGE_NAME=${{ env.IMAGE_NAME }}

View File

@ -11,20 +11,23 @@ jobs:
containerise: containerise:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Get tag - name: Get tag
id: vars id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Create a new container builder - name: Set up Docker Buildx
run: docker buildx create --name builder && docker buildx use builder uses: docker/setup-buildx-action@v1
- name: Build the container image
run: docker buildx build --platform linux/amd64 --tag $IMAGE_NAME .
- name: Log into GitHub Container Registry - name: Log into GitHub Container Registry
run: echo "${{ secrets.REGISTRY_ACCESS_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin run: echo "${{ secrets.REGISTRY_ACCESS_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image to GitHub Container Registry - name: Build and push
env: uses: docker/build-push-action@v2
RELEASE_TAG: ${{ steps.vars.outputs.tag }} with:
run: | platforms: linux/amd64
REF_TAG=ghcr.io/meeb/$IMAGE_NAME:$RELEASE_TAG push: true
docker tag $IMAGE_NAME $REF_TAG tags: ghcr.io/meeb/${{ env.IMAGE_NAME }}:${{ env.RELEASE_TAG }}
docker push $REF_TAG cache-from: type=registry,ref=ghcr.io/meeb/${{ env.IMAGE_NAME }}:${{ env.RELEASE_TAG }}
cache-to: type=inline
build-args: |
IMAGE_NAME=${{ env.IMAGE_NAME }}
RELEASE_TAG=${{ steps.vars.outputs.tag }}