-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
39 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,54 @@ | ||
name: Deploy Images to GitHub Container Registry | ||
|
||
on: push | ||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE_NAME: ghcr.io/${{ github.repository }} | ||
PLATFORMS: linux/amd64,linux/arm64 | ||
|
||
jobs: | ||
push-store-image: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: "Checkout GitHub Action" | ||
uses: actions/checkout@main | ||
|
||
- name: "Login to GitHub Container Registry" | ||
uses: docker/login-action@v1 | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{github.actor}} | ||
password: ${{secrets.CONTAINER_REGISTRY_TOKEN}} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }} | ||
|
||
- name: "Build Image and Push to Container Registry" | ||
run: | | ||
docker build . --tag ghcr.io/${{github.repository}}:${{github.ref_name}} | ||
docker push ghcr.io/${{github.repository}}:${{github.ref_name}} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.IMAGE_NAME }} | ||
|
||
- name: "Build Image as latest and Push to Container Registry" | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
platforms: ${{ env.PLATFORMS }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Build and push Docker image as latest | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
docker build . --tag ghcr.io/${{github.repository}}:latest | ||
docker push ghcr.io/${{github.repository}}:latest | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
platforms: ${{ env.PLATFORMS }} | ||
tags: ${{ steps.meta.outputs.tags }},${{ env.IMAGE_NAME }}:latest | ||
labels: ${{ steps.meta.outputs.labels }} |