Skip to content

Commit

Permalink
Workflow optimizations
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Kacper Żuk (Neti) <117277751+kacperzuk-neti@users.noreply.github.com>
  • Loading branch information
lukasz-wal and kacperzuk-neti authored Jul 26, 2024
1 parent 511d6e3 commit f4711dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
32 changes: 9 additions & 23 deletions .github/workflows/deploy-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,12 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Read version from file
run: |
CURRENT_VERSION=$(cargo pkgid --manifest-path fplus-http-server/Cargo.toml | cut -d'#' -f2)
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
- name: Install cargo-edit
run: cargo install cargo-edit

- name: Update version
run: cargo set-version ${{ inputs.version }}

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Run cargo check
run: cargo check

Expand All @@ -39,20 +31,14 @@ jobs:
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
# - name: Commit version change
# run: |
# git commit -am "Update version to ${{ inputs.version }}"
# git push origin main
- name: Commit version change
run: |
git commit -am "Update version to ${{ inputs.version }}"
git push origin main
call-release-workflow:
runs-on: ubuntu-latest
needs: [check-version, update-lock-and-commit]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: "Check build and push release"
uses: ./.github/workflows/release-new-version.yml
with:
version: ${{ inputs.version }}
needs: check-version
uses: ./.github/workflows/release-new-version.yml
with:
version: ${{ inputs.version }}
secrets: inherit
23 changes: 9 additions & 14 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ jobs:
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Run tests
env:
GH_PRIVATE_KEY: ${{ secrets.GH_PRIVATE_KEY }}
Expand All @@ -97,9 +94,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand Down Expand Up @@ -128,10 +122,11 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
flavor: latest=false
images: public.ecr.aws/f4h6r4m9/${{ env.ECR_REPOSITORY }}
tags: |
type=semver,pattern={{version}},value=v${{ inputs.version }}
type=ref,event=branch
type=semver,pattern={{version}},value=v${{ inputs.version }},enable=${{inputs.version != ''}}
type=raw,value={{branch}},enable=${{inputs.version != ''}}
type=ref,event=pr,pattern={{branch}}
- name: Build tag and push Docker image
Expand All @@ -144,9 +139,9 @@ jobs:
cache-to: type=gha,mode=max
github-token: ${{ secrets.GITHUB_TOKEN }}

# - name: Create and push tag
# if: inputs.version != ''
# run: |
# TAG_NAME="v${{ steps.meta.outputs.tags }}"
# git tag $TAG_NAME
# git push origin $TAG_NAME
- name: Create and push tag
if: ${{ github.ref == format('refs/heads/{0}', 'main') && inputs.version != '' }}
run: |
TAG_NAME="v${{ steps.meta.outputs.tags }}"
git tag $TAG_NAME
git push origin $TAG_NAME

0 comments on commit f4711dd

Please sign in to comment.