Add Dockerfile for devourer with build-go and debian-slim base #11
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
name: Publish | |
on: | |
push: | |
env: | |
TAG_NAME: devourer:${{ github.sha }} | |
BUILD_VERSION: ${{ github.sha }} | |
GITHUB_IMAGE_REPO: ghcr.io/${{ github.repository_owner }}/devourer | |
GITHUB_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/devourer:${{ github.sha }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build Docker image | |
run: docker build . -t ${{ env.TAG_NAME }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Rename image | |
run: docker tag ${{ env.TAG_NAME }} ${{ env.GITHUB_IMAGE_NAME }} | |
- name: Push image | |
run: docker push ${{ env.GITHUB_IMAGE_NAME }} | |
release-ghcr: | |
runs-on: ubuntu-latest | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: extract tag | |
id: tag | |
run: | | |
TAG=$(echo ${{ github.ref }} | sed -e "s#refs/tags/##g") | |
echo "tag=$TAG" >> $GITHUB_OUTPUT | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Pull Docker image | |
run: docker pull ${{ env.GITHUB_IMAGE_NAME }} | |
- name: Rename Docker image (tag name) | |
run: docker tag ${{ env.GITHUB_IMAGE_NAME }} "${{ env.GITHUB_IMAGE_REPO }}:${{ steps.tag.outputs.tag }}" | |
- name: Rename Docker image (latest) | |
run: docker tag ${{ env.GITHUB_IMAGE_NAME }} "${{ env.GITHUB_IMAGE_REPO }}:latest" | |
- name: Push Docker image (tag name) | |
run: docker push "${{ env.GITHUB_IMAGE_REPO }}:${{ steps.tag.outputs.tag }}" | |
- name: Push Docker image (latest) | |
run: docker push "${{ env.GITHUB_IMAGE_REPO }}:latest" |