From b54686e8cdf8e6c75424e7098ebeb5368f1cd1ba Mon Sep 17 00:00:00 2001 From: Ray Lyon <36998292+skoobasteeve@users.noreply.github.com> Date: Tue, 5 Apr 2022 20:22:37 -0400 Subject: [PATCH] new example --- .github/workflows/docker-image.yml | 48 +++++++++++++++++++----------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index fc5a8d4..f5f817b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,28 +1,40 @@ -name: Docker Image CI +name: Create and publish a Docker image on: push: - branches: [ main ] - pull_request: - branches: [ main ] + branches: ['main'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: - - build: - + build-and-push-image: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - uses: actions/checkout@v3 - env: - github_pat: ${{ secrets.CONTAINER_PAT }} + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.CONTAINER_PAT }} - - - name: Build the Docker image - run: docker build . --file Dockerfile --tag telegram-moviebot:$(date +%s) - - - name: Authenticate to the container registry - run: echo $github_pat | docker login ghcr.io -u skoobasteeve --password-stdin - - - name: Push the image to container registry - run: docker push ghcr.io/skoobasteeve/telegram-moviebot:latest + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}