diff --git a/.github/workflows/build-dockerhub.yml b/.github/workflows/build-dockerhub.yml index 8628cfc..cbac1fb 100644 --- a/.github/workflows/build-dockerhub.yml +++ b/.github/workflows/build-dockerhub.yml @@ -13,10 +13,6 @@ jobs: build: runs-on: ubuntu-latest environment: PROD - env: - CARGO_SERVER_SSL_CA: ${{ secrets.SERVER_SSL_CA }} - CARGO_SERVER_SSL_CERT: ${{ secrets.SERVER_SSL_CERT }} - CARGO_SERVER_SSL_KEY: ${{ secrets.SERVER_SSL_KEY }} steps: - name: Checkout the code @@ -34,16 +30,9 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Convert environment variables to Base64 - id: convert_env - run: | - echo "::set-env name=CARGO_SERVER_SSL_CA_BASE64::$(echo -n $CARGO_SERVER_SSL_CA | base64)" - echo "::set-env name=CARGO_SERVER_SSL_CERT_BASE64::$(echo -n $CARGO_SERVER_SSL_CERT | base64)" - echo "::set-env name=CARGO_SERVER_SSL_KEY_BASE64::$(echo -n $CARGO_SERVER_SSL_KEY | base64)" - - name: Build and deploy images env: - CARGO_SERVER_SSL_CA_BASE64: ${{ env.CARGO_SERVER_SSL_CA_BASE64 }} - CARGO_SERVER_SSL_CERT_BASE64: ${{ env.CARGO_SERVER_SSL_CERT_BASE64 }} - CARGO_SERVER_SSL_KEY_BASE64: ${{ env.CARGO_SERVER_SSL_KEY_BASE64 }} + CARGO_SERVER_SSL_CA: ${{ secrets.SERVER_SSL_CA }} + CARGO_SERVER_SSL_CERT: ${{ secrets.SERVER_SSL_CERT }} + CARGO_SERVER_SSL_KEY: ${{ secrets.SERVER_SSL_KEY }} run: bash dockerhub.sh ${{ github.event.inputs.version }} diff --git a/dockerhub.sh b/dockerhub.sh index b59d902..c6d1c1d 100644 --- a/dockerhub.sh +++ b/dockerhub.sh @@ -28,6 +28,10 @@ if ! [[ "$PATCH" =~ ^[0-9]+$ ]]; then exit 1 fi +CARGO_SERVER_SSL_CA_BASE64=$(echo "$CARGO_SERVER_SSL_CA" | base64) +CARGO_SERVER_SSL_CERT_BASE64=$(echo "$CARGO_SERVER_SSL_CERT" | base64) +CARGO_SERVER_SSL_KEY_BASE64=$(echo "$CARGO_SERVER_SSL_KEY" | base64) + # Validate if CARGO_SERVER_SSL_CA, CARGO_SERVER_SSL_CERT, and CARGO_SERVER_SSL_KEY are in base64 format if ! [[ "$CARGO_SERVER_SSL_CA_BASE64" =~ ^[A-Za-z0-9+/=]+$ ]]; then echo "Error: CARGO_SERVER_SSL_CA is not in base64 format."