From 4bbbfcc577de14a0094f53acbe3a9d606c25753e Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Wed, 4 Feb 2026 22:51:17 +0100 Subject: [PATCH] ffs --- .forgejo/workflows/playing-around.yaml | 87 +++++++++++--------------- 1 file changed, 36 insertions(+), 51 deletions(-) diff --git a/.forgejo/workflows/playing-around.yaml b/.forgejo/workflows/playing-around.yaml index 8c5f829..12b049c 100644 --- a/.forgejo/workflows/playing-around.yaml +++ b/.forgejo/workflows/playing-around.yaml @@ -1,70 +1,55 @@ -# This workflow will build and test the Rails application - -name: Build and Test Rails Application +name: Build and Push Docker Image on: push: - branches: [ main ] + branches: + - main pull_request: - branches: [ main ] + branches: + - main + +env: + DOCKER_TLS_CERTDIR: /certs + RAILS_ENV: production + # GitHub/Forgejo equivalent of CI_REGISTRY_IMAGE + commit refs + CONTAINER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.ref_name }}-${{ github.sha }} jobs: build: runs-on: docker services: - postgres: - image: postgres:latest - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: debshots_test + docker: + image: docker:20.10.16-dind + options: --privileged ports: - - 5432:5432 - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 + - 2375:2375 + env: + DOCKER_TLS_CERTDIR: /certs steps: - - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.2.4 + - name: Set up Docker CLI + uses: docker/setup-buildx-action@v3 - - name: Install dependencies + - name: Docker info + run: docker info + + - name: Log in to container registry run: | - gem install bundler - bundle install + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login \ + -u "${{ secrets.REGISTRY_USER }}" \ + --password-stdin \ + ${{ secrets.REGISTRY_URL }} - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '14' - - - name: Install Yarn - run: npm install -g yarn - - - name: Install Node.js dependencies - run: yarn install - - - name: Set up database + - name: Build Docker image run: | - bundle exec rails db:create db:migrate - env: - RAILS_ENV: test - DATABASE_URL: postgres://postgres:postgres@localhost:5432/debshots_test + docker build -t "$CONTAINER_IMAGE" . + docker tag "$CONTAINER_IMAGE" "${{ secrets.REGISTRY_IMAGE }}:latest" - - name: Run tests - run: bundle exec rails test - env: - RAILS_ENV: test - DATABASE_URL: postgres://postgres:postgres@localhost:5432/debshots_test - - - name: Build assets - run: bundle exec rails assets:precompile - env: - RAILS_ENV: production + - name: Push Docker images + run: | + docker push "$CONTAINER_IMAGE" + docker push "${{ secrets.REGISTRY_IMAGE }}:latest"