From e9bd8409de4d3c2da5b7982d542b3ac337614144 Mon Sep 17 00:00:00 2001 From: Tom Bland Date: Tue, 24 Oct 2023 10:08:32 +0100 Subject: [PATCH 1/2] modify workflow to publish docker image on release --- .github/workflows/ci.yml | 24 +----------------------- .github/workflows/publish.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9af8a9..55b2c7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: Test -on: [push] +on: [push, workflow_call] jobs: qa: @@ -26,25 +26,3 @@ jobs: run: pip install -r requirements-dev.txt - name: Run tests run: pytest - - publish: - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - needs: test - steps: - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Get image metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }} - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - push: true - tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..9fc8f9b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +on: [release] + +jobs: + test: + uses: ./.github/workflows/ci.yml + + publish: + runs-on: ubuntu-latest + needs: test + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Get image metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file From 72f20f714148d5555ff832609607dab6a6e223c8 Mon Sep 17 00:00:00 2001 From: Tom Bland Date: Tue, 24 Oct 2023 11:59:06 +0100 Subject: [PATCH 2/2] add on pull_request Co-authored-by: Adrian D'Alessandro --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55b2c7b..2edbe66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: Test -on: [push, workflow_call] +on: [push, pull_request, workflow_call] jobs: qa: