From a9b12afe8542dafbe21d6d621a21c28cfac36d4a Mon Sep 17 00:00:00 2001 From: flifloo Date: Fri, 16 Feb 2024 21:41:55 +0100 Subject: [PATCH] Migrate CI --- .forgejo/workflows/docker.yaml | 42 ++++++++++++++++++++++++++++++++++ .gitlab-ci.yml | 25 -------------------- 2 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 .forgejo/workflows/docker.yaml delete mode 100644 .gitlab-ci.yml diff --git a/.forgejo/workflows/docker.yaml b/.forgejo/workflows/docker.yaml new file mode 100644 index 0000000..1ba89c0 --- /dev/null +++ b/.forgejo/workflows/docker.yaml @@ -0,0 +1,42 @@ +name: Build Docker image and publish + +on: [push] + +env: + DOCKER_REPOSITORY: "git.flifloo.fr" + +jobs: + docker: + runs-on: docker + + container: + image: docker:cli + env: + DOCKER_HOST: tcp://dind:2375 + + services: + dind: + image: docker:dind + cmd: [ "dockerd", "-H", "tcp://0.0.0.0:2375", "--tls=false" ] + + steps: + - name: "Setup env" + id: env + run: | + echo "DOCKER_TAG=$DOCKER_REPOSITORY/$(echo "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]'):latest" >> "$GITHUB_ENV" + apk add --no-cache git nodejs + + - name: "Login to Docker repository" + id: login + run: docker login -u "$GITHUB_ACTOR" -p "${{ secrets.PACKAGE_TOKEN }}" "$DOCKER_REPOSITORY" + + - name: "Get repo" + uses: https://code.forgejo.org/actions/checkout@v4 + + - name: "Build Docker image" + id: build + run: docker buildx build --pull --platform linux/amd64 -t "$DOCKER_TAG" . + + - name: "Publish Docker image" + id: push + run: docker push "$DOCKER_TAG" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 0a4f3ec..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,25 +0,0 @@ -docker-build: - image: docker:latest - stage: build - services: - - docker:dind - before_script: - - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - # Default branch leaves tag empty (= latest tag) - # All other branches are tagged with the escaped branch name (commit ref slug) - script: - - | - if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then - tag="" - echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'" - else - tag=":$CI_COMMIT_REF_SLUG" - echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag" - fi - - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" . - - docker push "$CI_REGISTRY_IMAGE${tag}" - # Run this job in a branch where a Dockerfile exists - rules: - - if: $CI_COMMIT_BRANCH - exists: - - Dockerfile