From 8c2f3c7602105bd2ff5393fa956ffa326f9883a5 Mon Sep 17 00:00:00 2001 From: Maciej Lebiest <68295743+Szwendacz99@users.noreply.github.com> Date: Fri, 3 Mar 2023 21:38:49 +0100 Subject: [PATCH] Update docker-image.yml --- .github/workflows/docker-image.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d657a63..816a1d8 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,16 +3,25 @@ name: Docker Image CI on: push: branches: [ "main" ] - pull_request: - branches: [ "main" ] jobs: build: runs-on: ubuntu-latest + permissions: + packages: write + contents: read steps: - uses: actions/checkout@v3 - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) + run: docker build . --file Dockerfile --tag my-image-name:latest + - name: Log in to registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + - name: Push image + run: | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME + TAG=$(date +"%Y-%m-%dT%H-%M") + docker tag $IMAGE_NAME $IMAGE_ID:$TAG + docker push $IMAGE_ID:$TAG