From c796c14449f31683aa58a545acf13f1e9d7741e8 Mon Sep 17 00:00:00 2001 From: Hanjun Kim Date: Fri, 8 Nov 2024 14:42:20 +0800 Subject: [PATCH] build: add docker action (#154) ## Description it'll publish ghcr.io/milkyway-labs/milkywayd docker image to the GitHub container registry Closes: #XXXX --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/milkyway-labs/milkyway/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://docs.cosmos.network/v0.44/building-modules/intro.html) - [ ] included the necessary unit and integration [tests](https://github.com/milkyway-labs/milkyway/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- .github/workflows/docker.yml | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..abe80070f --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,68 @@ +name: Docker + +on: + workflow_dispatch: + push: + branches: + - "main" + tags: + - "v*" + paths: + - "**.go" + - "go.mod" + - "go.sum" + pull_request: + branches: + - "main" + paths: + - "**.go" + - "go.mod" + - "go.sum" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: milkywayd + +jobs: + milkywayd: + name: Milkywayd + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + outputs: + tags: ${{ steps.meta.outputs.tags }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Create the builder + uses: docker/build-push-action@v4 + with: + context: . + file: ./contrib/images/milkyway-builder/Dockerfile + load: true + tags: milkywaylabs/builder:latest + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + file: Dockerfile + push: ${{ startsWith(github.ref, 'refs/tags') }} # push image only for tags + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}