Skip to content

gh: cache

gh: cache #78

name: Publish Packages to Docker Hub
on:
push:
branches:
- develop
paths:
- 'packages/hop-node/**'
- 'packages/v2-explorer-backend/**'
- 'packages/api/**'
- 'packages/explorer-backend/**'
- 'packages/stats-worker/**'
jobs:
package-updates:
name: Check for package updates
uses: ./.github/workflows/modified-packages.yml
with:
package-names: 'hop-node:v2-explorer-backend:api:explorer-backend:stats-worker'
publish-docker:
name: Publish Docker
needs: package-updates
runs-on: ubuntu-latest
strategy:
matrix:
package-name: ${{ fromJson(needs.package-updates.outputs.modified-packages) }}
steps:
- name: Checkout code
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb
- name: Login to Docker Hub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check Package Updates
id: check-package-updates
uses: ./.github/actions/check-package-updates
with:
package-name: ${{ matrix.package-name }}
- name: Set Docker Tags
id: set-docker-tag
run: |
# Modify any discrepancies in the package name vs the image name
if [ "${{ matrix.package-name }}" == "api" ]; then
echo "IMAGE_NAME=hopprotocol/hop-api" >> $GITHUB_OUTPUT
else
echo "IMAGE_NAME=hopprotocol/${{ matrix.package-name }}" >> $GITHUB_OUTPUT
fi
# Set the correct version to release
if [ "${{ steps.check-package-updates.outputs.package-version-changed }}" == "true" ]; then
echo "DOCKER_TAG=latest" >> $GITHUB_OUTPUT
else
echo "DOCKER_TAG=unstable" >> $GITHUB_OUTPUT
fi
- name: Publish Docker Image (${{ steps.set-docker-tag.outputs.DOCKER_TAG }})
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0
with:
context: .
file: ./packages/${{ matrix.package-name }}/Dockerfile
tags: ${{ steps.set-docker-tag.outputs.IMAGE_NAME }}:${{ steps.set-docker-tag.outputs.DOCKER_TAG }}
push: true