Skip to content

Commit

Permalink
Rewriting the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
julialawrence authored Oct 19, 2023
1 parent c5da892 commit 5f05956
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ on:
push:
tags:
- '*'

release:
types: [published]

permissions:
packages: write
contents: read
jobs:
build-and-push:
runs-on: ubuntu-latest
Expand All @@ -13,25 +18,24 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and Push Docker Image
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
docker buildx create --use
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/${{ github.repository }}:$LATEST_TAG \
-t ghcr.io/${{ github.repository }}:latest \
-f Dockerfile .
docker buildx stop ${GITHUB_RUN_ID}
env:
DOCKER_CLI_AGGREGATE: 1

- name: Clean up
run: |
docker buildx rm --all
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 5f05956

Please sign in to comment.