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 }}