diff --git a/.github/workflows/publish-apiserver.yml b/.github/workflows/publish-apiserver.yml new file mode 100644 index 0000000..7ba11d4 --- /dev/null +++ b/.github/workflows/publish-apiserver.yml @@ -0,0 +1,47 @@ +# Create a new release when a tag is pushed, create a docker image and push it to docker hub +name: Publish ApiServer +on: + push: + tags: + - 'v*' +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '^1.22.1' + - name: Build + env: + CGO_ENABLED: 0 + run: | + cd apiserver + go build + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_CREATION_TOKEN }} + with: + tag_name: apiserver-${{ github.ref }} + release_name: ApiServer ${{ github.ref }} + draft: false + prerelease: false + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and Push Docker Image + uses: docker/build-push-action@v4 + with: + context: apiserver + file: ./apiserver/Dockerfile + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/statusphere-apiserver:${{ github.ref_name }} + ${{ secrets.DOCKERHUB_USERNAME }}/statusphere-apiserver:latest