Build and Push Docker Image #87
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: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - master | |
| schedule: | |
| - cron: '0 0 * * *' # Runs daily at midnight | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.get_latest_tag.outputs.tag }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Get latest dbsync tag | |
| id: get_latest_tag | |
| run: | | |
| latest_tag=$(curl -s https://api.github.com/repos/intersectmbo/cardano-db-sync/releases/latest | jq -r .tag_name) | |
| echo Target build tag: $latest_tag | |
| if [[ -z "$latest_tag" || "$latest_tag" == "null" ]]; then | |
| echo "Failed to get latest tag"; exit 1 | |
| fi | |
| echo "tag=$latest_tag" >> $GITHUB_OUTPUT | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ github.repository_owner }}/cardano-db-sync:${{ steps.get_latest_tag.outputs.tag }} | |
| build-args: | | |
| DBSYNC_TAG=${{ steps.get_latest_tag.outputs.tag }} |