From 8db8dfbf071e72dcda3956ca91abe250221ade82 Mon Sep 17 00:00:00 2001 From: Aaro Koivukangas Date: Mon, 6 Oct 2025 16:06:49 +0300 Subject: [PATCH] changed github actions to better match other procjects --- .github/workflows/build.yaml | 47 ++++++++++++++++-------------------- .gitignore | 2 ++ Dockerfile.self-host | 1 - 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4b22ded..c0c1089 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,36 +10,31 @@ env: IMAGE_NAME: ${{ github.event_name == 'release' && 'brewery' || 'brewery-staging' }} jobs: - push_package: - if: ${{ github.event_name == 'release' || (github.event_name == 'push' && !contains(github.event.head_commit.message, '#no-deploy')) }} + build_log_output-server: runs-on: ubuntu-latest - permissions: - packages: write - contents: read steps: - uses: actions/checkout@v4 - - name: Build image - run: docker build . --file Dockerfile.self-host --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" + - name: Extract Docker image metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ vars.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} - - name: Log in to registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - # - - name: Push image - run: | - IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - # This changes all uppercase characters to lowercase. - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - # This strips the git ref prefix from the version. - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - - # This strips the "v" prefix from the tag name. - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - - VERSION=latest - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + - name: Build and push Docker image (server) + uses: docker/build-push-action@v6 + with: + context: "{{defaultContext}}" + target: server + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + annotations: ${{ steps.meta.outputs.annotations }} diff --git a/.gitignore b/.gitignore index cfa10e4..f8b6e57 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ vendor coverage + +.env diff --git a/Dockerfile.self-host b/Dockerfile.self-host index a3e8f1e..e5f9045 100644 --- a/Dockerfile.self-host +++ b/Dockerfile.self-host @@ -63,7 +63,6 @@ USER rails:rails ENV RAILS_LOG_TO_STDOUT="1" \ RAILS_SERVE_STATIC_FILES="true" - # Entrypoint prepares the database. ENTRYPOINT ["/rails/docker-entrypoint.sh"]