From 097dbb391a7a836f9800ded27839336f8b52644c Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sat, 27 Jan 2024 12:44:54 -0500 Subject: [PATCH] fix: Improve workflow for main branch and PRs (#17) This makes it so that the main branch will push images but PRs won't. This also puts integration tests back in the `+all` target. --- .github/workflows/build-pr.yml | 27 +++++++++++++++++++++++++++ .github/workflows/build.yml | 12 ++++++------ .github/workflows/tag.yml | 2 +- Earthfile | 4 ++++ 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build-pr.yml diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml new file mode 100644 index 00000000..9e79c94e --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,27 @@ +name: Earthly PR +build + +on: + pull_request: + +env: + FORCE_COLOR: 1 + +jobs: + build: + timeout-minutes: 60 + runs-on: ubuntu-latest + + steps: + - uses: earthly/actions-setup@v1 + with: + use-cache: true + version: v0.8.2 + + # Setup repo and add caching + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.ref }} + + - name: Run build + run: earthly --ci -P +build + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 15757646..ab41bccf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,7 @@ -name: Earthly +build +name: Earthly main branch +build on: workflow_dispatch: - merge_group: - pull_request: push: branches: - main @@ -15,17 +13,19 @@ jobs: build: permissions: packages: write - timeout-minutes: 30 + timeout-minutes: 60 runs-on: ubuntu-latest steps: - uses: earthly/actions-setup@v1 with: use-cache: true - version: v0.8.0 + version: v0.8.2 # Setup repo and add caching - uses: actions/checkout@v4 + with: + ref: main - name: Login to GitHub Container Registry uses: docker/login-action@v3 @@ -35,4 +35,4 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Run build - run: earthly --push --ci -P +all + run: earthly --push --ci -P +build diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index ee2bf0f2..034139bb 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -1,4 +1,4 @@ -name: Earthly +tag +name: Earthly tag +build on: push: diff --git a/Earthfile b/Earthfile index 31e301f2..c924376f 100644 --- a/Earthfile +++ b/Earthfile @@ -5,6 +5,10 @@ IMPORT github.com/blue-build/earthly-lib/cargo AS cargo ARG --global IMAGE=ghcr.io/blue-build/cli all: + BUILD +build + BUILD +integration-tests --NIGHTLY=true --NIGHTLY=false + +build: BUILD +default BUILD +nightly