Skip to content

Commit

Permalink
add github ci config
Browse files Browse the repository at this point in the history
  • Loading branch information
zelje committed Apr 8, 2024
1 parent 181ff1e commit 09e1f98
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: container-images


on:
push:
branches: [ "main" ]
tags: [ "v*" ]

jobs:
build-container-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3

- run: echo "IMAGE_TAG=main" >> $GITHUB_ENV
if: github.ref_name == 'main'
- run: echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')

- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to docker.io
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_UID }}
password: ${{ secrets.DOCKER_HUB_PAT }}

- name: Build and push image for tags
uses: docker/build-push-action@v5
if: startsWith(github.ref, 'refs/tags/v')
with:
context: . # Because GH actions are for kids and put protection on everything; https://stackoverflow.com/a/71159809/11276254
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
ghcr.io/${{ github.repository }}:latest
${{ secrets.DOCKER_HUB_REPO }}:${{ env.IMAGE_TAG }}
${{ secrets.DOCKER_HUB_REPO }}:latest
- name: Build and push image for main
uses: docker/build-push-action@v5
if: github.ref_name == 'main'
with:
context: . # Because GH actions are for kids and put protection on everything; https://stackoverflow.com/a/71159809/11276254
# platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}

0 comments on commit 09e1f98

Please sign in to comment.