mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
Merge pull request #2 from teddy931130/devops_task
Fine-tune build-and-push workflow
This commit is contained in:
commit
576caa3ee2
2 changed files with 34 additions and 15 deletions
43
.github/workflows/build.yml
vendored
43
.github/workflows/build.yml
vendored
|
|
@ -8,7 +8,6 @@ on:
|
|||
description: "Create and push a new tag?"
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
pull_request:
|
||||
branches: [master]
|
||||
types:
|
||||
|
|
@ -19,6 +18,7 @@ env:
|
|||
AWS_REGION: "eu-central-1"
|
||||
ECR_REPO_NAME: "limechain-devops-task/go-ethereum"
|
||||
IAM_OIDC_ROLE_NAME: "go-ethereum-github-actions-role"
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
|
|
@ -27,8 +27,8 @@ permissions:
|
|||
|
||||
jobs:
|
||||
build-and-push:
|
||||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CI:Build')
|
||||
runs-on: ubuntu:22.04
|
||||
# if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CI:Build')
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
|
|
@ -37,6 +37,12 @@ jobs:
|
|||
fetch-depth: 0
|
||||
ref: ${{ github.ref_name }}
|
||||
|
||||
### NOT using dependency caches, since using GitHub-hosted runners. More info at the URL below:
|
||||
### https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#about-caching-workflow-dependencies
|
||||
# - uses: actions/setup-go@v5
|
||||
# with:
|
||||
# go-version-file: "go.mod"
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
|
|
@ -65,20 +71,29 @@ jobs:
|
|||
fi
|
||||
echo "new-tag=${NEW_TAG}" >> $GITHUB_OUTPUT
|
||||
|
||||
# - name: Build and push Docker Image
|
||||
# run: |
|
||||
# FULL_ECR_URL="${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO_NAME }}"
|
||||
# NEW_TAG="${{ steps.get-latest-tag.outputs.new-tag }}"
|
||||
- name: Build and push Docker Image
|
||||
env:
|
||||
COMMIT: ${{ github.sha }}
|
||||
run: |
|
||||
FULL_ECR_URL="${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO_NAME }}"
|
||||
NEW_TAG="${{ steps.get-latest-tag.outputs.new-tag }}"
|
||||
|
||||
# docker build \
|
||||
# --build-arg VAR="VALUE" \
|
||||
# -t "${FULL_ECR_URL}:${NEW_TAG}" \
|
||||
# -f Dockerfile .
|
||||
# define build args for the image
|
||||
COMMIT=${COMMIT:0:7}
|
||||
VERSION=$NEW_TAG
|
||||
BUILDNUM=$(git rev-list --count HEAD)
|
||||
|
||||
# docker push "${FULL_ECR_URL}:${NEW_TAG}"
|
||||
docker build \
|
||||
--build-arg COMMIT="${COMMIT}" \
|
||||
--build-arg VERSION="${VERSION}" \
|
||||
--build-arg BUILDNUM="${BUILDNUM}" \
|
||||
-t "${FULL_ECR_URL}:${NEW_TAG}" \
|
||||
-f Dockerfile .
|
||||
|
||||
- name: Notify PR of New Tag
|
||||
if: ${{ inputs.create_tag }} == 'true'
|
||||
docker push "${FULL_ECR_URL}:${NEW_TAG}"
|
||||
|
||||
- name: Create new tag and notify PR
|
||||
if: ${{ inputs.create_tag }}
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
|
|
|||
6
Makefile
6
Makefile
|
|
@ -2,7 +2,7 @@
|
|||
# with Go source code. If you know what GOPATH is then you probably
|
||||
# don't need to bother with make.
|
||||
|
||||
.PHONY: geth all test lint fmt clean devtools help
|
||||
.PHONY: geth all test lint fmt clean devtools docker-login help
|
||||
|
||||
GOBIN = ./build/bin
|
||||
GO ?= latest
|
||||
|
|
@ -47,6 +47,10 @@ devtools:
|
|||
@type "solc" 2> /dev/null || echo 'Please install solc'
|
||||
@type "protoc" 2> /dev/null || echo 'Please install protoc'
|
||||
|
||||
#? docker-login: Login to the ECR repo containing the go-ethereum image.
|
||||
docker-login:
|
||||
aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 861276097334.dkr.ecr.eu-central-1.amazonaws.com
|
||||
|
||||
#? help: Get more info on make commands.
|
||||
help: Makefile
|
||||
@echo ''
|
||||
|
|
|
|||
Loading…
Reference in a new issue