Skip to content

Commit

Permalink
Release workflow placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-wal authored Jul 19, 2024
1 parent 608337e commit 56aa615
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 13 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/deploy-new-version.yml
Original file line number Diff line number Diff line change
@@ -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 }}
43 changes: 30 additions & 13 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
push:
branches:
- main
workflow_call:
inputs:
version:
required: true
type: string

env:
ECR_REPOSITORY: "filplus-backend"
Expand Down Expand Up @@ -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

0 comments on commit 56aa615

Please sign in to comment.