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?"
|
description: "Create and push a new tag?"
|
||||||
required: false
|
required: false
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
types:
|
types:
|
||||||
|
|
@ -19,6 +18,7 @@ env:
|
||||||
AWS_REGION: "eu-central-1"
|
AWS_REGION: "eu-central-1"
|
||||||
ECR_REPO_NAME: "limechain-devops-task/go-ethereum"
|
ECR_REPO_NAME: "limechain-devops-task/go-ethereum"
|
||||||
IAM_OIDC_ROLE_NAME: "go-ethereum-github-actions-role"
|
IAM_OIDC_ROLE_NAME: "go-ethereum-github-actions-role"
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
id-token: write
|
id-token: write
|
||||||
|
|
@ -27,8 +27,8 @@ permissions:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CI:Build')
|
# if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CI:Build')
|
||||||
runs-on: ubuntu:22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
|
|
@ -37,6 +37,12 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.ref_name }}
|
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
|
- name: Configure AWS Credentials
|
||||||
uses: aws-actions/configure-aws-credentials@v4
|
uses: aws-actions/configure-aws-credentials@v4
|
||||||
with:
|
with:
|
||||||
|
|
@ -65,20 +71,29 @@ jobs:
|
||||||
fi
|
fi
|
||||||
echo "new-tag=${NEW_TAG}" >> $GITHUB_OUTPUT
|
echo "new-tag=${NEW_TAG}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
# - name: Build and push Docker Image
|
- name: Build and push Docker Image
|
||||||
# run: |
|
env:
|
||||||
# FULL_ECR_URL="${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO_NAME }}"
|
COMMIT: ${{ github.sha }}
|
||||||
# NEW_TAG="${{ steps.get-latest-tag.outputs.new-tag }}"
|
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 \
|
# define build args for the image
|
||||||
# --build-arg VAR="VALUE" \
|
COMMIT=${COMMIT:0:7}
|
||||||
# -t "${FULL_ECR_URL}:${NEW_TAG}" \
|
VERSION=$NEW_TAG
|
||||||
# -f Dockerfile .
|
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
|
docker push "${FULL_ECR_URL}:${NEW_TAG}"
|
||||||
if: ${{ inputs.create_tag }} == 'true'
|
|
||||||
|
- name: Create new tag and notify PR
|
||||||
|
if: ${{ inputs.create_tag }}
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
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
|
# with Go source code. If you know what GOPATH is then you probably
|
||||||
# don't need to bother with make.
|
# 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
|
GOBIN = ./build/bin
|
||||||
GO ?= latest
|
GO ?= latest
|
||||||
|
|
@ -47,6 +47,10 @@ devtools:
|
||||||
@type "solc" 2> /dev/null || echo 'Please install solc'
|
@type "solc" 2> /dev/null || echo 'Please install solc'
|
||||||
@type "protoc" 2> /dev/null || echo 'Please install protoc'
|
@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: Get more info on make commands.
|
||||||
help: Makefile
|
help: Makefile
|
||||||
@echo ''
|
@echo ''
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue