⚙️ .github: use docker's actions

master
neingeist 2 years ago
parent 0edcbe5966
commit 385b84a14d

@ -4,7 +4,6 @@ on: [push, workflow_dispatch]
env: env:
ENDPOINT: "neingeist/docker-mod-openssh-server-tweaks" ENDPOINT: "neingeist/docker-mod-openssh-server-tweaks"
BRANCH: "master"
jobs: jobs:
build: build:
@ -12,24 +11,35 @@ jobs:
permissions: permissions:
packages: write packages: write
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- name: Build image -
run: | name: Docker - Meta
docker build --no-cache -t ${{ github.sha }} . id: meta
- name: Tag image uses: docker/metadata-action@v4
if: ${{ github.ref == format('refs/heads/{0}', env.BRANCH) && env.ENDPOINT != 'user/endpoint' }} with:
run: | images: ghcr.io/${{ env.ENDPOINT }}
docker tag ${{ github.sha }} ${ENDPOINT} tags: |
docker tag ${{ github.sha }} ${ENDPOINT}:${{ github.sha }} type=sha,prefix=,format=short,enable=true
docker tag ${{ github.sha }} ghcr.io/${ENDPOINT} type=ref,event=branch
docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${{ github.sha }} # set latest tag for default branch
- name: Login to GitHub Container Registry type=raw,value=latest,enable={{is_default_branch}}
if: ${{ github.ref == format('refs/heads/{0}', env.BRANCH) && env.ENDPOINT != 'user/endpoint' }} -
run: | name: Docker - Set up Docker Buildx
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin uses: docker/setup-buildx-action@v2
- name: Push tags to GitHub Container Registry -
if: ${{ github.ref == format('refs/heads/{0}', env.BRANCH) && env.ENDPOINT != 'user/endpoint' }} name: Docker - Login to GitHub Container Registry
run: | if: github.ref_type == 'branch'
docker push ghcr.io/${ENDPOINT}:${{ github.sha }} uses: docker/login-action@v2
docker push ghcr.io/${ENDPOINT} with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker - Build and push
uses: docker/build-push-action@v3
with:
push: ${{ github.ref_type == 'branch' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Loading…
Cancel
Save