Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker hub release workflow #41

Merged
merged 3 commits into from
Mar 1, 2023
Merged

Add Docker hub release workflow #41

merged 3 commits into from
Mar 1, 2023

Conversation

bobbyiliev
Copy link
Collaborator

@bobbyiliev bobbyiliev commented Feb 27, 2023

Adding a release workflow to publish the Docker image for the datagen to Docker Hub.

Before we merge this, we need to add a DOCKER_USERNAME and DOCKER_PASSWORD secret.

Closes #37

Copy link
Contributor

@chuck-alt-delete chuck-alt-delete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are a couple of suggested changes:

name: Publish Docker image

on:
  push:
    branches: ["main"]
    tags: ["v*"]

jobs:
  push_to_registry:
    name: Push Docker image to Docker Hub
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@v3

      - name: Use buildx for multi-platform images
        uses: docker/setup-buildx-action@v2

      - name: Log in to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      
      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: materialize/datagen
          tags: |
            type=semver,pattern={{major}}.{{minor}}
      
      - name: Build and push Docker image
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

Instead of using SHA values for the action version, I just stuck with latest major version. I think that will suffice. If we want SHA values, we should look up what the latest for each is, because I think some of the ones in this PR are quite out of date.

I added a step for buildx, because it apparently handles multi platform builds for us (i.e. ARM and x86).

For the meta step, I added semantic versioning. It will automatically create a docker tag based on the semantic version as well as a latest tag. See example. So for a tag v0.1.0 it would create docker tag 0.1.0 and latest.

What do you think?

@bobbyiliev
Copy link
Collaborator Author

Good points! Just updated this with the suggested changes!

Copy link
Member

@benesch benesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added Docker credentials to this repository. The username is materializebot and the password is in DOCKER_HUB_MATERIALIZEBOT_API_KEY. Here's an example from another repository: https://github.com/MaterializeInc/rr/blob/0afcd9677bbf8a3a851318b592fbb23c3aece57a/.github/workflows/ci.yml#L23-L24

@bobbyiliev
Copy link
Collaborator Author

Thank you @benesch! I just updated the credentials accordingly!

@bobbyiliev bobbyiliev merged commit b908ec9 into main Mar 1, 2023
@bobbyiliev bobbyiliev deleted the docker-hub-workflow branch March 1, 2023 16:12
recursethis pushed a commit to recursethis/materialize-datagen that referenced this pull request Feb 26, 2024
* Add Docker hub release workflow

* Update docker workflow

* Update the Docker hub creds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Add a workflow to build a Docker image and push it to Docker Hub
3 participants