Skip to content

Commit

Permalink
Gha test. (#156)
Browse files Browse the repository at this point in the history
* Gha test.

* A test.

* Fix build.

* Another test.

* Another test.

* Also update release.
  • Loading branch information
SebastianStehle authored Nov 30, 2022
1 parent 3483592 commit 73492bb
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 144 deletions.
108 changes: 34 additions & 74 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,84 +21,48 @@ jobs:
- name: Inject slug/short variables
uses: rlespinasse/[email protected]

- name: Calculate Version
env:
BUILD_NUMBER: ${{ github.run_number }}
run: |
echo "BUILD_NUMBER=$(($BUILD_NUMBER + 1000))" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Cache Docker layers
uses: actions/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: BUILD
uses: docker/[email protected]
with:
push: false
load: true
build-args: "NOTIFO__VERSION=1.0.0-dev-${{ env.BUILD_NUMBER }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
tags: notifo-tmp

- name: Export Image
run: docker save notifo-tmp | gzip > notifo-tmp.tar.gz

- name: Save Image to Cache
uses: actions/[email protected]
with:
path: notifo-tmp.tar.gz
key: notifo-dev-image-${{ github.sha }}

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: squidex/notifo-build

test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Calculate Version
env:
BUILD_NUMBER: ${{ github.run_number }}
run: |
echo "BUILD_NUMBER=$(($BUILD_NUMBER + 1000))" >> $GITHUB_ENV
- name: Checkout
uses: actions/[email protected]

- name: Inject slug/short variables
uses: rlespinasse/[email protected]

- name: Get Image From Cache
uses: actions/[email protected]
with:
path: notifo-tmp.tar.gz
key: notifo-dev-image-${{ github.sha }}

- name: Load Image
run: docker load < notifo-tmp.tar.gz

- name: Pull from Cache
run: docker pull squidex/notifo-build

- name: Replace Image Name1
uses: mikefarah/[email protected]
with:
cmd: yq e '.services.notifo1.image = "notifo-tmp"' -i backend/tests/docker-compose.yml
cmd: yq e '.services.notifo1.image = "squidex/notifo-build"' -i backend/tests/docker-compose.yml

- name: Replace Image Name2
uses: mikefarah/[email protected]
with:
cmd: yq e '.services.notifo2.image = "notifo-tmp"' -i backend/tests/docker-compose.yml
cmd: yq e '.services.notifo2.image = "squidex/notifo-build"' -i backend/tests/docker-compose.yml

- name: Inject Google Credentials
run: mkdir secrets && echo "$GOOGLE__KEYFILE" >| secrets/keyfile.json
Expand Down Expand Up @@ -144,7 +108,7 @@ jobs:
if: failure()
uses: jwalton/[email protected]
with:
images: 'notifo-tmp,squidex/resizer'
images: 'squidex/notifo-build,squidex/resizer'
tail: '100'

- name: Cleanup Test
Expand All @@ -155,42 +119,38 @@ jobs:
publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/[email protected]

- name: Inject slug/short variables
uses: rlespinasse/[email protected]

- name: Calculate Version
env:
BUILD_NUMBER: ${{ github.run_number }}
run: |
echo "BUILD_NUMBER=$(($BUILD_NUMBER + 1000))" >> $GITHUB_ENV
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Login to Docker Hub
uses: docker/[email protected]
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Get Image From Cache
if: github.event_name != 'pull_request'
uses: actions/[email protected]
- name: BUILD
uses: docker/[email protected]
with:
path: notifo-tmp.tar.gz
key: notifo-dev-image-${{ github.sha }}

- name: Load Image
if: github.event_name != 'pull_request'
run: docker load < notifo-tmp.tar.gz

- name: Rename Tags
if: github.event_name != 'pull_request'
run: |
docker tag notifo-tmp squidex/notifo:dev
docker tag notifo-tmp squidex/notifo:dev-${{ env.BUILD_NUMBER }}
- name: Push Tags
if: github.event_name != 'pull_request'
run: |
docker push squidex/notifo:dev
docker push squidex/notifo:dev-${{ env.BUILD_NUMBER }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
squidex/notifo:dev
squidex/notifo:dev-${{ env.BUILD_NUMBER }}
111 changes: 41 additions & 70 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,20 @@ jobs:
- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Cache Docker layers
uses: actions/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: BUILD
uses: docker/[email protected]
with:
push: false
load: true
tags: notifo-tmp
push: true
build-args: "NOTIFO__VERSION=${{ env.GITHUB_REF_SLUG }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

- name: Export Image
run: docker save notifo-tmp | gzip > notifo-tmp.tar.gz

- name: Save Image to Cache
uses: actions/[email protected]
with:
path: notifo-tmp.tar.gz
key: notifo-release-image-${{ github.sha }}

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
cache-from: type=gha
cache-to: type=gha,mode=max
tags: squidex/notifo-build

test:
needs: build
Expand All @@ -63,25 +46,19 @@ jobs:

- name: Inject slug/short variables
uses: rlespinasse/[email protected]

- name: Get Image From Cache
uses: actions/[email protected]
with:
path: notifo-tmp.tar.gz
key: notifo-release-image-${{ github.sha }}

- name: Load Image
run: docker load < notifo-tmp.tar.gz

- name: Pull from Cache
run: docker pull squidex/notifo-build

- name: Replace Image Name1
uses: mikefarah/[email protected]
with:
cmd: yq e '.services.notifo1.image = "notifo-tmp"' -i backend/tests/docker-compose.yml
cmd: yq e '.services.notifo1.image = "squidex/notifo-build"' -i backend/tests/docker-compose.yml

- name: Replace Image Name2
uses: mikefarah/[email protected]
with:
cmd: yq e '.services.notifo2.image = "notifo-tmp"' -i backend/tests/docker-compose.yml
cmd: yq e '.services.notifo2.image = "squidex/notifo-build"' -i backend/tests/docker-compose.yml

- name: Inject Google Credentials
run: mkdir secrets && echo "$GOOGLE__KEYFILE" >| secrets/keyfile.json
Expand Down Expand Up @@ -127,7 +104,7 @@ jobs:
if: failure()
uses: jwalton/[email protected]
with:
images: 'notifo-tmp,squidex/resizer'
images: 'squidex/notifo-build,squidex/resizer'
tail: '100'

- name: Cleanup Test
Expand All @@ -139,42 +116,42 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Inject slug/short variables
uses: rlespinasse/[email protected]

- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Get Major Version
id: version
uses: rishabhgupta/split-by@v1
with:
string: "${{ env.GITHUB_REF_SLUG }}"
split-by: "."

- name: Get Image From Cache
uses: actions/[email protected]
with:
path: notifo-tmp.tar.gz
key: notifo-release-image-${{ github.sha }}
- name: Set up QEMU
uses: docker/[email protected]

- name: Load Image
run: docker load < notifo-tmp.tar.gz
- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Rename Tags
run: |
docker tag notifo-tmp squidex/notifo:latest
docker tag notifo-tmp squidex/notifo:${{ env.GITHUB_REF_SLUG }}
docker tag notifo-tmp squidex/notifo:${{ steps.version.outputs._0 }}
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push Tags
run: |
docker push squidex/notifo:latest
docker push squidex/notifo:${{ env.GITHUB_REF_SLUG }}
docker push squidex/notifo:${{ steps.version.outputs._0 }}
- name: BUILD
uses: docker/[email protected]
with:
push: true
build-args: "NOTIFO__VERSION=${{ env.GITHUB_REF_SLUG }}"
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
squidex/notifo:latest
squidex/notifo:${{ env.GITHUB_REF_SLUG }}
squidex/notifo:${{ steps.version.outputs._0 }}
release:
needs: publish
Expand All @@ -185,21 +162,15 @@ jobs:

- name: Inject slug/short variables
uses: rlespinasse/[email protected]

- name: Get Image From Cache
uses: actions/[email protected]
with:
path: notifo-tmp.tar.gz
key: notifo-release-image-${{ github.sha }}

- name: Load Image
run: docker load < notifo-tmp.tar.gz

- name: Pull from Cache
run: docker pull squidex/notifo-build

- name: Make directories
run: sudo mkdir /build /release

- name: Create container
run: docker create --name notifo-container notifo-tmp:latest
run: docker create --name notifo-container squidex/notifo-build

- name: Get binaries
run: sudo docker cp notifo-container:/app/. /build
Expand Down

0 comments on commit 73492bb

Please sign in to comment.