From ef2d23de8ad075a1674c3045b6c45f343dc07d7e Mon Sep 17 00:00:00 2001 From: Davide Imola Date: Mon, 10 Feb 2025 10:38:11 +0100 Subject: [PATCH] feat: ci for docker --- .github/workflows/ci.yaml | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..4e9bfae --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,49 @@ +name: CI + +on: + push: + branches: + - 'main' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Get Vars + id: get_vars + run: | + echo "ts=$(date +%s)" >> $GITHUB_OUTPUT + echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: | + ghcr.io/${{ github.repository }}/api + tag-sha: true + tag-semver: | + {{version}} + {{major}}.{{minor}} + tag-custom: | + ${{ steps.get_vars.outputs.branch }}-${{ steps.get_vars.outputs.sha }}-${{ steps.get_vars.outputs.ts }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to Digital Ocean Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v4 + with: + context: ./snackjob-backend + push: true + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_mata.outputs.labels }} + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file