diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..7a0fe76 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,56 @@ +name: ci + +# Build and run all tests. +# - Triggers: All pushes and pull requests on any branch. +# - Runs on: All repositories (including forks) + +on: + push: + branches: ['**'] + + pull_request: + branches: ['**'] + + workflow_dispatch: # Allows manual dispatch + +# Prevents overlapping runs of this workflow on the same branch. +# If multiple commits are pushed in quick succession, only the most recent run will complete. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-test: + if: ${{ !(github.repository == 'FirebirdSQL/firebird-docker' && github.ref == 'refs/heads/master') }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 10 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Install tools + shell: pwsh + run: | + Install-Module InvokeBuild -Force + + - name: Build + shell: pwsh + run: | + Invoke-Build + + - name: Test + shell: pwsh + run: | + Invoke-Build Test + + - name: Upload logs + uses: actions/upload-artifact@v4 + if: always() + with: + name: ci-logs-${{ github.run_id }} + path: generated/logs + retention-days: 7 # Short log retention for CI runs diff --git a/.github/workflows/on-pull-request.yaml b/.github/workflows/on-pull-request.yaml deleted file mode 100644 index 133906a..0000000 --- a/.github/workflows/on-pull-request.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: on-pull-request - -on: [pull_request] - -jobs: - - build-test: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 10 - - - name: Install tools - shell: pwsh - run: | - Install-Module InvokeBuild -Force - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Build - shell: pwsh - run: | - Invoke-Build - - - name: Test - shell: pwsh - run: | - Invoke-Build Test - - - name: Upload logs - uses: actions/upload-artifact@v4 - if: always() - with: - name: logs - path: generated/logs diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 7225aa7..827c36d 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,36 +1,41 @@ name: publish +# Build, test and publish official Docker images. +# - Triggers: Pushes to master and scheduled weekly runs. +# - Runs on: Only the official repository (FirebirdSQL/firebird-docker) + on: push: branches: - master + schedule: - - cron: "0 0 * * 1" - workflow_dispatch: + - cron: "0 0 * * 1" # Every Monday at midnight + workflow_dispatch: # Allows manual dispatch + +# Only a single instance of this workflow can be in execution at a given time. concurrency: group: ${{ github.workflow }} jobs: - - build-test-publish: - if: ${{ github.event_name != 'schedule' || github.repository == 'FirebirdSQL/firebird-docker' }} + build-test-and-publish: + if: ${{ github.repository == 'FirebirdSQL/firebird-docker' }} runs-on: ubuntu-latest - steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 10 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Install tools shell: pwsh run: | Install-Module InvokeBuild -Force - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Build shell: pwsh run: | @@ -52,13 +57,10 @@ jobs: run: | Invoke-Build Publish - - name: Log out from Docker Hub - run: | - docker logout - - name: Upload logs uses: actions/upload-artifact@v4 if: always() with: - name: logs + name: publish-logs-${{ github.run_id }} path: generated/logs + retention-days: 30 # Longer log retention for published images