Skip to content

Commit

Permalink
Merge pull request #8 from jjuarez/feature/docker-build-by-target
Browse files Browse the repository at this point in the history
Feature/docker build by target
  • Loading branch information
jjuarez authored Jul 16, 2022
2 parents 0844642 + a229bdd commit 0164449
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 58 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci-golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: dagger/ci/golang

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
ci-golang:
runs-on: ubuntu-latest
env:
DAGGER_LOGLEVEL: "info"
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dagger
uses: dagger/dagger-for-github@v3
with:
install-only: true

- name: Dagger project update
run: dagger project update

- name: Dagger do test
run: dagger do test --log-format plain --log-level ${DAGGER_LOGLEVEL}

- name: Dagger do build
run: dagger do build --log-format plain --log-level ${DAGGER_LOGLEVEL}
32 changes: 0 additions & 32 deletions .github/workflows/ci.yml

This file was deleted.

36 changes: 16 additions & 20 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
name: docker
name: dagger/docker

on:
pull_request:

jobs:
docker:
runs-on: ubuntu-latest
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DAGGER_LOGLEVEL: "debug"
steps:
- name: Clone repository
- name: Checkout code
uses: actions/checkout@v2

- name: Docker build
- name: Install dagger
uses: dagger/dagger-for-github@v3
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
with:
version: 0.2
cmds: |
project update
do docker_build
install-only: true

- name: Docker push
uses: dagger/dagger-for-github@v3
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
with:
version: 0.2
cmds: |
project update
do docker_push --log-level=debug
- name: Dagger project update
run: dagger project update

- name: Docker build
run: dagger do docker_build --log-format plain --log-level ${DAGGER_LOGLEVEL}

- name: Docker release
run: dagger do release --log-format plain --log-level ${DAGGER_LOGLEVEL}
19 changes: 13 additions & 6 deletions dagger.cue
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (

dagger.#Plan & {
client: env: {
DOCKER_USERNAME: string | "jjuarez"
DOCKER_USERNAME: string
DOCKER_PASSWORD: dagger.#Secret
}

client: filesystem: ".": read: {
contents: dagger.#FS
exclude: [
Expand All @@ -23,9 +24,15 @@ dagger.#Plan & {
}

actions: {
params: image: {
registry: "docker.io"
namespace: "jjuarez"
name: "dagger-golang-example"
tag: "latest"
}

docker_build: docker.#Dockerfile & {
source: client.filesystem.".".read.contents
dockerfile: path: "Dockerfile"
auth: {
"index.docker.io": {
username: client.env.DOCKER_USERNAME
Expand All @@ -34,17 +41,17 @@ dagger.#Plan & {
}
}

docker_push: docker.#Push & {
release: docker.#Push & {
image: docker_build.output
dest: "docker.io/jjuarez/dagger-golang-example:latest"
dest: "\(params.image.registry)/\(params.image.namespace)/\(params.image.name):\(params.image.tag)"
}

go_build: go.#Build & {
build: go.#Build & {
source: client.filesystem.".".read.contents
package: "./..."
}

go_test: go.#Test & {
test: go.#Test & {
source: client.filesystem.".".read.contents
package: "./..."
}
Expand Down

0 comments on commit 0164449

Please sign in to comment.