Skip to content

Commit

Permalink
Merge pull request #24 from seungkyua/docker_build_and_push
Browse files Browse the repository at this point in the history
Build and push docker image when merged
  • Loading branch information
seungkyua authored Sep 8, 2021
2 parents 4249f0e + b4f4349 commit ed1e5ad
Show file tree
Hide file tree
Showing 3 changed files with 51 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-pPush-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-info:${{ github.head_ref }}
build-args: |
PRV_GITHUB_TOKEN=${{ secrets.PRV_GITHUB_TOKEN }}
27 changes: 18 additions & 9 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@ on:
push:
branches:
- main
release:
types: [published]

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-info
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-info: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-info
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 ed1e5ad

Please sign in to comment.