Skip to content

Commit d71b1db

Browse files
authored
Merge pull request #1681 from cosmos/publish-docker-gh
Publish faucet docker using GitHub
2 parents 6f2820d + 6111839 commit d71b1db

File tree

2 files changed

+60
-29
lines changed

2 files changed

+60
-29
lines changed

.circleci/config.yml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ workflows:
2020
- coverage:
2121
requires:
2222
- build
23-
- faucet-docker
2423

2524
jobs:
2625
build:
@@ -402,31 +401,3 @@ jobs:
402401
./scripts/simapp50/stop.sh
403402
./scripts/simapp50/slow_stop.sh
404403
./scripts/wasmd/stop.sh
405-
faucet-docker:
406-
docker:
407-
- image: cimg/go:1.17.8
408-
steps:
409-
- run:
410-
name: Install Git Large File Storage (LFS)
411-
command: |
412-
sudo apt update
413-
sudo apt install git-lfs
414-
- checkout
415-
- setup_remote_docker:
416-
version: default
417-
- run:
418-
name: Build faucet Docker image
419-
# Use ${CIRCLE_TAG}
420-
command: |
421-
docker build --pull -t "confio/faucet:$CIRCLE_SHA1" -f packages/faucet/Dockerfile .
422-
- run:
423-
name: Check docker image can be executed
424-
command: |
425-
docker run --rm "confio/faucet:$CIRCLE_SHA1" version
426-
docker run --rm "confio/faucet:$CIRCLE_SHA1" generate
427-
# - run:
428-
# name: Push image to Docker Hub
429-
# command: |
430-
# docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS"
431-
# docker push "confio/faucet:$CIRCLE_SHA1"
432-
# docker logout

.github/workflows/faucet.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Create and publish faucet Docker image
2+
3+
on:
4+
push:
5+
branches: ["main", "publish-docker-gh"]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: cosmos/cosmjs-faucet
10+
11+
jobs:
12+
build-and-push-image:
13+
runs-on: ubuntu-latest
14+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
15+
permissions:
16+
contents: read
17+
packages: write
18+
attestations: write
19+
id-token: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
lfs: true
25+
26+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
27+
- name: Log in to the Container registry
28+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
35+
- name: Extract metadata (tags, labels) for Docker
36+
id: meta
37+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
41+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
42+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
43+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
44+
- name: Build and push Docker image
45+
id: push
46+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
47+
with:
48+
context: .
49+
file: packages/faucet/Dockerfile
50+
push: true
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
54+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
55+
- name: Generate artifact attestation
56+
uses: actions/attest-build-provenance@v2
57+
with:
58+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
59+
subject-digest: ${{ steps.push.outputs.digest }}
60+
push-to-registry: true

0 commit comments

Comments
 (0)