1
0
Fork 0
mirror of https://github.com/kastenhq/kubestr.git synced 2024-12-15 17:50:57 +00:00

Update Docker_Publish action to use official images (#94)

* upadting to use new token

* remove comment

* Updating docker publish action to use official images
This commit is contained in:
Sirish Bathina 2021-10-21 16:49:10 -10:00 committed by GitHub
parent a92d89f012
commit 95bf14e588
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,9 +9,12 @@ on:
# Publish `v1.2.3` tags as releases. # Publish `v1.2.3` tags as releases.
tags: tags:
- v* - v*
pull_request:
branches: [ master ]
env: env:
IMAGE_NAME: kubestr REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs: jobs:
push: push:
@ -23,30 +26,28 @@ jobs:
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build image - name: Log into ${{ env.REGISTRY }}
run: docker build . --file Dockerfile --tag $IMAGE_NAME if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into GitHub Container Registry # Extract metadata (tags, labels) for Docker
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin # https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Push image to GitHub Container Registry # Build and push Docker image with Buildx (don't push on PR)
run: | # https://github.com/docker/build-push-action
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME - name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
# Change all uppercase to lowercase with:
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') context: .
push: ${{ github.event_name != 'pull_request' }}
# Strip git ref prefix from version tags: ${{ steps.meta.outputs.tags }}
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') labels: ${{ steps.meta.outputs.labels }}
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION