Add docker build and publish to ghcr.io #481
This file contains hidden or 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: 'Indexer' | |
| on: | |
| pull_request: | |
| branches: [main, develop] | |
| push: | |
| branches: [main, develop] | |
| jobs: | |
| build: | |
| name: Run Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js 18 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install | |
| working-directory: ./indexer | |
| - name: Build | |
| run: tsc | |
| working-directory: ./indexer | |
| docker-publish: | |
| name: Build and Publish Docker Image to GHCR | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract branch and sha for tags | |
| id: vars | |
| run: | | |
| BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | sed 's/\//-/g') | |
| SHA=$(echo $GITHUB_SHA | cut -c1-7) | |
| echo "BRANCH=$BRANCH" >> $GITHUB_ENV | |
| echo "SHA=$SHA" >> $GITHUB_ENV | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: Dockerfile.development | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/indexer-kadena:${{ env.BRANCH }} | |
| ghcr.io/${{ github.repository_owner }}/indexer-kadena:sha-${{ env.SHA }} |