Skip to content

Commit

Permalink
Merge pull request #11 from seungkyua/docker_build_and_push
Browse files Browse the repository at this point in the history
Build and push docker image when pr or merged
  • Loading branch information
seungkyua authored Sep 8, 2021
2 parents bea43ac + 747f7ad commit 707946b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/deploy-image-with-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Create and publish a package
on:
pull_request:
branches:
- main
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: seungkyua/tks-contract:${{ github.head_ref }}
build-args: |
PRV_GITHUB_TOKEN=${{ secrets.PRV_GITHUB_TOKEN }}
30 changes: 21 additions & 9 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
name: Create and publish a package
on:
release:
types: [published]
push:
branches:
- main

jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build container image
uses: docker/build-push-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
repository: ${{ github.repository }}/tks-contract
tag_with_ref: true
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: seungkyua/tks-contract:latest
build-args: |
PRV_GITHUB_TOKEN=${{ secrets.PRV_GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FROM golang:1.16.3-stretch AS builder
LABEL AUTHOR Seungkyu Ahn ([email protected])

ARG PRV_GITHUB_TOKEN
RUN go env -w GOPRIVATE=github.com/openinfradev/tks-contract
RUN git config --global url."https://x-access-token:${PRV_GITHUB_TOKEN}@github.com".insteadOf "https://github.com"

RUN mkdir -p /build
WORKDIR /build

Expand Down

0 comments on commit 707946b

Please sign in to comment.