hi server update #61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build test project | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
IMAGE_NAME: meow | |
jobs: | |
init: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
target: | |
- go_builder | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Load cache for builder - ${{ matrix.target }} | |
uses: actions/cache@v3 | |
with: | |
path: dockerCache | |
key: docker-cache-${{ runner.os }}-${{ matrix.target }} | |
- name: Preparing builder - ${{ matrix.target }} | |
run: | | |
docker buildx build -f ./base.Dockerfile \ | |
-t base:${{ matrix.target }} \ | |
--target ${{ matrix.target }} \ | |
--cache-from type=gha,src=dockerCache \ | |
--cache-to type=gha,mode=max,src=dockerCache \ | |
. | |
- name: Save docker image | |
run: | | |
docker images | |
mkdir images | |
docker save -o images/${{ matrix.target }}.tar base:${{ matrix.target }} | |
- name: Save image ${{ matrix.target }} to cache | |
uses: actions/cache@v3 | |
with: | |
path: images | |
key: docker-images-${{ runner.os }} | |
backend: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
needs: | |
- init | |
strategy: | |
matrix: | |
target: | |
- pingserver | |
- hiserver | |
steps: | |
- name: Log into registry | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u "${{ github.actor }}" --password-stdin | |
- uses: actions/checkout@v4 | |
- name: Restore cached dependencies | |
uses: actions/cache@v3 | |
with: | |
path: images | |
key: docker-images-${{ runner.os }} | |
- name: Load image | |
run: | | |
docker load --input images/go_builder.tar | |
docker image ls -a | |
- name: Start build ${{ matrix.target }} | |
run: | | |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-${{ matrix.target }} | |
echo IMAGE_ID=$IMAGE_ID | |
PATH_TO_MAIN=./apps/${{ matrix.target }} | |
echo PATH_TO_MAIN=$PATH_TO_MAIN | |
docker buildx build -f $PATH_TO_MAIN/Dockerfile \ | |
--build-arg PATH_TO_MAIN=$PATH_TO_MAIN \ | |
--tag $IMAGE_ID:latest \ | |
--cache-from type=gha \ | |
--cache-to type=gha,mode=max \ | |
-t bld:${{ matrix.target }} \ | |
. | |
docker push $IMAGE_ID:latest |