Skip to content

Commit

Permalink
Merge pull request #3 from propeller-heads/INFRA-116-Get-rid-of-GH_TO…
Browse files Browse the repository at this point in the history
…KEN-in-github-workflows

fix: INFRA-116-Change gh_token to app
  • Loading branch information
kvvit authored Oct 14, 2024
2 parents 8a5e879 + a3f1853 commit 0c9f60b
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
tests-and-lints:
uses: ./.github/workflows/tests-and-lints-template.yaml
secrets:
infura_api_key: ${{ secrets.INFURA_API_KEY }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

45 changes: 40 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,57 @@ jobs:
tests-and-lints:
uses: ./.github/workflows/tests-and-lints-template.yaml
secrets:
gh_token: ${{ secrets.GH_TOKEN }}
infura_api_key: ${{ secrets.INFURA_API_KEY }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

protosim_py_release:
name: Protosim-Py Release
runs-on: ubuntu-latest
needs:
- tests-and-lints
steps:
- name: Generate a token
id: generate-token
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.app_id }}
private_key: ${{ secrets.app_private_key }}

- name: Install git
run: sudo apt update && sudo apt install -y git

- name: Check out Repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup git to use https
run: |
git config --global credential.helper store
echo "https://${{ secrets.GH_TOKEN }}@github.com" > ~/.git-credentials
git config --global url."https://${{ secrets.GH_TOKEN }}@github.com".insteadOf ssh://github.com
echo "https://${{ steps.generate-token.outputs.token }}@github.com" > ~/.git-credentials
git config --global url."https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com".insteadOf ssh://github.com
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Install Maturin
run: |
python -m pip install --upgrade pip
pip install maturin
- name: Build protosim-py
run: |
cd protosim_py
maturin build --release
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -61,19 +78,32 @@ jobs:
needs:
- tests-and-lints
steps:
- name: Generate a token
id: generate-token
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.app_id }}
private_key: ${{ secrets.app_private_key }}

- name: Install git
run: sudo apt update && sudo apt install -y git

- name: Check out Repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup git to use https
run: |
git config --global credential.helper store
echo "https://${{ secrets.GH_TOKEN }}@github.com" > ~/.git-credentials
git config --global url."https://${{ secrets.GH_TOKEN }}@github.com".insteadOf ssh://github.com
echo "https://${{ steps.generate-token.outputs.token }}@github.com" > ~/.git-credentials
git config --global url."https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com".insteadOf ssh://github.com
- name: Set build variables
run: |
TAG=$(git describe --tags --abbrev=0)-SNAPSHOT.$(git rev-parse --short HEAD)
echo "IMAGE=827659017777.dkr.ecr.eu-central-1.amazonaws.com/propeller-searcher:$TAG" >> $GITHUB_ENV
- name: install-aws-cli
uses: unfor19/install-aws-cli-action@v1
with:
Expand All @@ -82,18 +112,22 @@ jobs:
arch: amd64
rootdir: ""
workdir: ""

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::827659017777:role/github-actions
audience: sts.amazonaws.com
aws-region: eu-central-1

- name: Setup BuildX
uses: docker/setup-buildx-action@v1

- name: Login to ECR
uses: docker/login-action@v1
with:
registry: 827659017777.dkr.ecr.eu-central-1.amazonaws.com

- name: Build
uses: docker/build-push-action@v2
with:
Expand All @@ -104,5 +138,6 @@ jobs:
tags: ${{ env.IMAGE }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Push
run: docker push $IMAGE
17 changes: 14 additions & 3 deletions .github/workflows/release_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@ jobs:
tests-and-lints:
uses: ./.github/workflows/tests-and-lints-template.yaml
secrets:
gh_token: ${{ secrets.GH_TOKEN }}
infura_api_key: ${{ secrets.INFURA_API_KEY }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

docker_release:
name: Docker Image Build
runs-on: ubuntu-latest
needs:
- tests-and-lints
steps:
- name: Generate a token
id: generate-token
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.app_id }}
private_key: ${{ secrets.app_private_key }}

- name: Install git
run: sudo apt update && sudo apt install -y git

- name: Check out Repo
uses: actions/checkout@v3
with:
Expand All @@ -31,8 +42,8 @@ jobs:
- name: Setup git to use https
run: |
git config --global credential.helper store
echo "https://${{ secrets.GH_TOKEN }}@github.com" > ~/.git-credentials
git config --global url."https://${{ secrets.GH_TOKEN }}@github.com".insteadOf ssh://github.com
echo "https://${{ steps.generate-token.outputs.token }}@github.com" > ~/.git-credentials
git config --global url."https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com".insteadOf ssh://github.com
- name: Set build variables
run: |
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/release_wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
tests-and-lints:
uses: ./.github/workflows/tests-and-lints-template.yaml
secrets:
gh_token: ${{ secrets.GH_TOKEN }}
infura_api_key: ${{ secrets.INFURA_API_KEY }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

build_python_wheel_linux:
uses: propeller-heads/ci-cd-templates/.github/workflows/release-python-package.yaml@main
Expand All @@ -29,7 +30,8 @@ jobs:
id-token: write
contents: read
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
with:
runs_on: 'ubuntu-latest'
yum_packages: "pkgconfig openssl-devel"
Expand All @@ -43,8 +45,9 @@ jobs:
id-token: write
contents: read
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
with:
runs_on: 'macos-latest'
package_root: "protosim_py"
use_maturin: true
use_maturin: true
4 changes: 3 additions & 1 deletion .github/workflows/tests-and-lints-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
type: number
default: 15
secrets:
infura_api_key:
required: true
app_id:
required: true
app_private_key:
Expand All @@ -23,7 +25,7 @@ permissions:

env:
CARGO_TERM_COLOR: always
#INFURA_API_KEY: ${{ secrets.infura_api_key }}
INFURA_API_KEY: ${{ secrets.infura_api_key }}

jobs:
compile_and_test:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/v2-build-and-deploy-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
image_tag: ${{ github.sha }}
image_name: propeller-searcher
secrets:
gh_token: ${{ secrets.GH_TOKEN }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

deploy-dev:
needs:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/v2-main-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ jobs:
tests-and-lints:
uses: ./.github/workflows/tests-and-lints-template.yaml
secrets:
gh_token: ${{ secrets.GH_TOKEN }}
infura_api_key: ${{ secrets.INFURA_API_KEY }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

check-release:
uses: propeller-heads/ci-cd-templates/.github/workflows/release-v2.yaml@main
Expand Down Expand Up @@ -51,7 +52,8 @@ jobs:
image_tag: ${{ needs.release.outputs.next_release_version }}
image_name: propeller-searcher
secrets:
gh_token: ${{ secrets.GH_TOKEN }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

promote-to-dev:
needs:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/v2-release-maintenance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ jobs:
tests-and-lints:
uses: ./.github/workflows/tests-and-lints-template.yaml
secrets:
gh_token: ${{ secrets.GH_TOKEN }}
infura_api_key: ${{ secrets.INFURA_API_KEY }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

check-release:
uses: propeller-heads/ci-cd-templates/.github/workflows/release-v2.yaml@main
Expand Down Expand Up @@ -52,4 +53,5 @@ jobs:
image_tag: ${{ needs.release.outputs.next_release_version }}
image_name: propeller-searcher
secrets:
gh_token: ${{ secrets.GH_TOKEN }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

0 comments on commit 0c9f60b

Please sign in to comment.