Skip to content

Merge branch '2-add-a-period-check-on-crontab-that-check-if-the-certi… #8

Merge branch '2-add-a-period-check-on-crontab-that-check-if-the-certi…

Merge branch '2-add-a-period-check-on-crontab-that-check-if-the-certi… #8

Workflow file for this run

name: Docker Image CI
on:
push:
branches: ["main"]
tags: ["*"]
pull_request:
branches: ["main"]
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Define variables
id: vars
run: |
echo "date=$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_OUTPUT
echo "short_sha=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_OUTPUT
echo "branch_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
echo "tag_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
- name: Build and push Docker image for Tags
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v4
with:
push: true
tags: ghcr.io/relybytes/nginx-certbot:${{ steps.vars.outputs.tag_name }}
- name: Build and push Docker image for Branches
if: startsWith(github.ref, 'refs/heads/')
uses: docker/build-push-action@v4
with:
push: true
tags: |
ghcr.io/relybytes/nginx-certbot:latest
ghcr.io/relybytes/nginx-certbot:${{ steps.vars.outputs.date }}-${{ steps.vars.outputs.short_sha }}
ghcr.io/relybytes/nginx-certbot:${{ steps.vars.outputs.branch_name }}-latest