From 56aa615288f3ed2ceba3b77b7774d86037ac8196 Mon Sep 17 00:00:00 2001 From: lukasz-wal <143998006+lukasz-wal@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:06:20 +0200 Subject: [PATCH] Release workflow placeholder --- .github/workflows/deploy-new-version.yml | 58 +++++++++++++++++++++++ .github/workflows/release-new-version.yml | 43 ++++++++++++----- 2 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/deploy-new-version.yml diff --git a/.github/workflows/deploy-new-version.yml b/.github/workflows/deploy-new-version.yml new file mode 100644 index 00000000..efb5a29c --- /dev/null +++ b/.github/workflows/deploy-new-version.yml @@ -0,0 +1,58 @@ +name: Deploy new version +run-name: New deployment for "${{ github.ref_name }}" triggered by ${{ github.actor }} + +on: + workflow_dispatch: + inputs: + version: + description: "Enter the version number" + required: true + default: "latest" + +jobs: + check-version: + runs-on: ubuntu-latest + + steps: + - 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 + + - name: Git config + run: | + 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 + + 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 }} diff --git a/.github/workflows/release-new-version.yml b/.github/workflows/release-new-version.yml index fc9a53c3..8ee81b55 100644 --- a/.github/workflows/release-new-version.yml +++ b/.github/workflows/release-new-version.yml @@ -6,6 +6,11 @@ on: push: branches: - main + workflow_call: + inputs: + version: + required: true + type: string env: ECR_REPOSITORY: "filplus-backend" @@ -119,17 +124,29 @@ jobs: mask-password: "true" registry-type: public - - name: Set IMAGE_TAG - run: | - IMAGE_TAG=$(echo ${{ github.ref_name }} | tr '/' '-') - echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV - - - name: Build tag and push Docker image - uses: docker/build-push-action@v6 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 with: - context: . - push: true - tags: public.ecr.aws/f4h6r4m9/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} - cache-from: type=gha - cache-to: type=gha,mode=max - github-token: ${{ secrets.GITHUB_TOKEN }} + images: public.ecr.aws/f4h6r4m9/${{ env.ECR_REPOSITORY }} + tags: | + type=semver,pattern={{version}},value=v${{ inputs.version }} + type=ref,event=branch + type=ref,event=pr,pattern={{branch}} + + # - name: Build tag and push Docker image + # uses: docker/build-push-action@v6 + # with: + # context: . + # push: true + # tags: ${{ steps.meta.outputs.tags }} + # cache-from: type=gha + # 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