Skip to content

Commit

Permalink
add push_git_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
kogeler committed Oct 9, 2024
1 parent 4310d81 commit 8e0a55c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/avail.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ on:
- .github/workflows/avail.yml
- config.yml

env:
RELEASE_REF: refs/heads/main
jobs:
build-binaries:
runs-on: ubuntu-latest
Expand All @@ -28,17 +26,18 @@ jobs:
fail-fast: false
matrix:
debian-versions: [bookworm]
rust-versions: [1.78.0]
rust-versions: [1.81.0]
clang-versions: [17]
rustc-targets: ["x86-64-v2", "x86-64-v3"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set environmental variables
run: |
echo "CODE_GIT_REPO=$(cat config.yml | yq -r '.avail.git_repo' | tr -d '\n')" >> "$GITHUB_ENV"
CODE_GIT_REF=$(cat config.yml | yq -r '.avail.git_ref' | tr -d '\n')
echo "CODE_GIT_REPO=$(cat config.yml | yq -r '.avail.code_git_repo' | tr -d '\n')" >> "$GITHUB_ENV"
CODE_GIT_REF=$(cat config.yml | yq -r '.avail.code_git_ref' | tr -d '\n')
echo "CODE_GIT_REF=${CODE_GIT_REF}" >> $GITHUB_ENV
echo "PUSH_GIT_REF=$(cat config.yml | yq -r '.avail.push_git_ref' | tr -d '\n')" >> "$GITHUB_ENV"
ENV_VERSION="debian-${{ matrix.debian-versions }}-rust-${{ matrix.rust-versions }}-clang-${{ matrix.clang-versions }}-${{ matrix.rustc-targets }}"
echo "BINARY_FILE_NAME=${CODE_GIT_REF}-${ENV_VERSION}" >> $GITHUB_ENV
echo "EXECUTE_WORKER_BINARY_FILE_NAME=${CODE_GIT_REF}-execute-worker-${ENV_VERSION}" >> $GITHUB_ENV
Expand All @@ -56,7 +55,7 @@ jobs:
cargo build --release --locked --target x86_64-unknown-linux-gnu
ls /opt/cargo_target/x86_64-unknown-linux-gnu/release
- name: "Create release"
if: ${{ github.ref == env.RELEASE_REF }}
if: ${{ github.ref == env.PUSH_GIT_REF }}
uses: "actions/github-script@v6"
with:
script: |
Expand All @@ -74,7 +73,7 @@ jobs:
core.notice(error.message);
}
- name: Upload binaries
if: ${{ github.ref == env.RELEASE_REF }}
if: ${{ github.ref == env.PUSH_GIT_REF }}
run: |
BINARIES_DIR=${CARGO_TARGET_DIR}/x86_64-unknown-linux-gnu/release
mv ${BINARIES_DIR}/avail-node ${BINARIES_DIR}/avail-${BINARY_FILE_NAME}
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/polkadot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ on:

env:
REGISTRY: ghcr.io
RELEASE_REF: refs/heads/main
jobs:
build-docker-images:
runs-on: ubuntu-latest
Expand All @@ -42,8 +41,9 @@ jobs:
run: |
echo "ENV_FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.ENV_IMAGE_NAME }}:debian-${{ matrix.debian-versions }}-rust-${{ matrix.rust-versions }}-clang-${{ matrix.clang-versions }}" >> "$GITHUB_ENV"
echo "image-name=${{ env.REGISTRY }}/${{ env.ENV_IMAGE_NAME }}" >> "$GITHUB_OUTPUT"
echo "CODE_GIT_REPO=$(cat config.yml | yq -r '.polkadot.git_repo' | tr -d '\n')" >> "$GITHUB_ENV"
echo "CODE_GIT_REF=$(cat config.yml | yq -r '.polkadot.git_ref' | tr -d '\n')" >> "$GITHUB_ENV"
echo "CODE_GIT_REPO=$(cat config.yml | yq -r '.polkadot.code_git_repo' | tr -d '\n')" >> "$GITHUB_ENV"
echo "CODE_GIT_REF=$(cat config.yml | yq -r '.polkadot.code_git_ref' | tr -d '\n')" >> "$GITHUB_ENV"
echo "PUSH_GIT_REF=$(cat config.yml | yq -r '.polkadot.push_git_ref' | tr -d '\n')" >> "$GITHUB_ENV"
- name: Check Docker image
run: |
if docker manifest inspect "${ENV_FULL_IMAGE_NAME}" > /dev/null 2>&1; then
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
GIT_REF=${{ env.CODE_GIT_REF }}
tags: test-build-image
- name: Push Docker image
if: ${{ env.CONTINUE_IMAGE_BUILD == 'true' && github.ref == env.RELEASE_REF }}
if: ${{ env.CONTINUE_IMAGE_BUILD == 'true' && github.ref == env.PUSH_GIT_REF }}
run: docker push ${{ env.ENV_FULL_IMAGE_NAME }}
build-binaries:
runs-on: ubuntu-latest
Expand All @@ -126,11 +126,12 @@ jobs:
uses: actions/checkout@v4
- name: Set environmental variables
run: |
echo "CODE_GIT_REPO=$(cat config.yml | yq -r '.polkadot.git_repo' | tr -d '\n')" >> "$GITHUB_ENV"
CODE_GIT_REF=$(cat config.yml | yq -r '.polkadot.git_ref' | tr -d '\n')
echo "CODE_GIT_REPO=$(cat config.yml | yq -r '.polkadot.code_git_repo' | tr -d '\n')" >> "$GITHUB_ENV"
CODE_GIT_REF=$(cat config.yml | yq -r '.polkadot.code_git_ref' | tr -d '\n')
echo "CODE_GIT_REF=${CODE_GIT_REF}" >> $GITHUB_ENV
IMAGE_NAME=$(cat config.yml | yq -r '.polkadot.image_name' | tr -d '\n')
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "PUSH_GIT_REF=$(cat config.yml | yq -r '.polkadot.push_git_ref' | tr -d '\n')" >> "$GITHUB_ENV"
BUILD_VERSION="debian-${{ matrix.debian-versions }}-rust-${{ matrix.rust-versions }}-clang-${{ matrix.clang-versions }}-${{ matrix.rustc-targets }}"
echo "BINARY_FILE_NAME=${CODE_GIT_REF}-${BUILD_VERSION}" >> $GITHUB_ENV
echo "EXECUTE_WORKER_BINARY_FILE_NAME=${CODE_GIT_REF}-execute-worker-${BUILD_VERSION}" >> $GITHUB_ENV
Expand Down Expand Up @@ -158,7 +159,7 @@ jobs:
cp ${BINARIES_DIR}/polkadot-execute-worker ${GITHUB_WORKSPACE}/artifacts
cp ${BINARIES_DIR}/polkadot-prepare-worker ${GITHUB_WORKSPACE}/artifacts
- name: Create GitHub release
if: ${{ github.ref == env.RELEASE_REF }}
if: ${{ github.ref == env.PUSH_GIT_REF }}
uses: "actions/github-script@v6"
with:
script: |
Expand All @@ -176,7 +177,7 @@ jobs:
core.notice(error.message);
}
- name: Upload binaries to GitHub release
if: ${{ github.ref == env.RELEASE_REF }}
if: ${{ github.ref == env.PUSH_GIT_REF }}
env:
GH_TOKEN: ${{ github.token }}
run: |
Expand All @@ -203,7 +204,7 @@ jobs:
with:
file: dockerfiles/Dockerfile-amd64
context: artifacts
push: ${{ github.ref == env.RELEASE_REF }}
push: ${{ github.ref == env.PUSH_GIT_REF }}
load: true
labels: ${{ steps.meta.outputs.labels }}
build-args: |
Expand Down

0 comments on commit 8e0a55c

Please sign in to comment.