From 751f74cb491661da424ef3c3a3d1caedcfb1625e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giosu=C3=A8=20Delgado?= <11545723+giosueDelgado@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:25:24 +0100 Subject: [PATCH] feat: Create main.yml --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8deb258 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + 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 + env: + REGISTRY: ghcr.io + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Define date and short SHA + 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 + - name: Build and push Docker image + 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 }}