Implement autofunding #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: 'Build Docker Image' | |
on: | |
pull_request: | |
types: | |
- synchronize | |
- ready_for_review | |
branches: | |
- master | |
paths-ignore: | |
- "charts/**/*" | |
concurrency: | |
group: ${{ github.head_ref }}-docker | |
cancel-in-progress: true | |
jobs: | |
bump_version: | |
name: Bump version | |
runs-on: ubuntu-2-core | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Bump Cargo version | |
id: bumping_version | |
run: | | |
hoprd_operator_version=$(grep "^version = " Cargo.toml | sed 's/.* "//' | sed 's/"$//' | tr -d '\n') | |
git_tag=$(git tag -l ${hoprd_operator_version}) | |
echo "Workspace version is ${hoprd_operator_version} while tagged is ${git_tag}" | |
if [ "${git_tag}" = "${hoprd_operator_version}" ]; then | |
patch_number=$(echo $git_tag | sed 's/.*\.//') | |
release_number=$(echo $git_tag | sed "s/\.${patch_number}//") | |
bump_version=${release_number}.$((patch_number + 1)) | |
echo "The version ${git_tag} already exists, bumping to version ${bump_version}"; | |
sed -i "s/^version = \"${git_tag}\"/version = \"${bump_version}\"/" Cargo.toml | |
echo "bumped_version=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
if: ${{ steps.bumping_version.outputs.bumped_version }} | |
with: | |
toolchain: stable | |
# Update Cargo.lock | |
- name: Build Cargo | |
uses: actions-rs/cargo@v1 | |
if: ${{ steps.bumping_version.outputs.bumped_version }} | |
with: | |
command: build | |
- name: Commit and push | |
if: ${{ steps.bumping_version.outputs.bumped_version }} | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "Bump to cargo version ${{ steps.bumping_version.outputs.bumped_version }}" | |
repository: . | |
commit_user_name: HOPR CI robot | |
commit_user_email: [email protected] | |
commit_author: HOPR CI robot <[email protected]> | |
skip_fetch: false | |
skip_checkout: false | |
create_branch: false | |
build: | |
name: Build docker | |
needs: bump_version | |
runs-on: ubuntu-2-core | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: kubernetes | |
- name: Set up Google Cloud Credentials | |
id: auth | |
uses: google-github-actions/auth@v1 | |
with: | |
token_format: "access_token" | |
credentials_json: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }} | |
- name: Set up Google Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
project_id: ${{ secrets.GOOGLE_HOPRASSOCIATION_PROJECT }} | |
install_components: beta | |
- name: Login Google Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: europe-west3-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.auth.outputs.access_token }} | |
- name: Build container image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: europe-west3-docker.pkg.dev/hoprassociation/docker-images/hoprd-operator:latest | |