Skip to content

Commit

Permalink
Merge pull request #5 from KnightChaser/development
Browse files Browse the repository at this point in the history
Move deployment DockerHub to ghcr.io
  • Loading branch information
KnightChaser committed Feb 3, 2024
2 parents 85c8a1d + 9bb2c3d commit ba26374
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: automatic-docker-deployment
name: automatic-build

on:
push:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -21,21 +25,34 @@ jobs:
- name: Build Go code
run: go build -v .

deploy:
deployment-ghcr:
runs-on: ubuntu-latest
needs: build

permissions:
contents: read
packages: write

steps:
- name: Checkout code
- name: Checkout GitHub repository
uses: actions/checkout@v4

- name: Login to Dockerhub
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and release to DockerHub
uses: docker/build-push-action@v2
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHP_ACCESS_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/aesir:latest
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit ba26374

Please sign in to comment.