From 05e561285ead8b2f4bb14ca962083fe8332763f9 Mon Sep 17 00:00:00 2001 From: TheDarkCode Date: Tue, 3 May 2022 02:33:17 +0200 Subject: [PATCH] =?UTF-8?q?a=C3=B1adidos=20variables=20de=20entorno=20de?= =?UTF-8?q?=20secrets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit arreglado cors Quitado .env Action paralelo y mas env Arreglos secrets --- .github/workflows/asw2122.yml | 25 +++++++++++++++---------- restapi/.env | 4 ---- restapi/Dockerfile | 11 ++++++++--- restapi/server.ts | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) delete mode 100644 restapi/.env diff --git a/.github/workflows/asw2122.yml b/.github/workflows/asw2122.yml index b3dec58..1f1d575 100644 --- a/.github/workflows/asw2122.yml +++ b/.github/workflows/asw2122.yml @@ -20,6 +20,11 @@ jobs: - uses: codecov/codecov-action@v2 unit-test-restapi: runs-on: ubuntu-latest + env: + MONGO_DB_URI: ${{ secrets.MONGO_DB_URI }} + SECRET_SALT: ${{ secrets.SECRET_SALT }} + SECRET: ${{ secrets.SECRET }} + PRUEBA: ${{ secrets.PRUEBA }} defaults: run: working-directory: restapi @@ -28,9 +33,6 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 - - run: touch .env - - run: echo "${{ secrets.ENV }}" > .env - - run: cp .env ./tests/.env - run: npm ci - run: npm test - uses: codecov/codecov-action@v2 @@ -49,38 +51,41 @@ jobs: docker-push-webapp: name: Push webapp Docker Image to GitHub Packages runs-on: ubuntu-latest - needs: [unit-test-webapp, unit-test-restapi] + needs: [unit-test-webapp] # needs: [e2e-tests] steps: - uses: actions/checkout@v2 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@3.04 + env: + API_URI: http://${{ secrets.DEPLOY_HOST }}:5000 with: name: arquisoft/dede_es4b/webapp username: ${{ github.actor }} password: ${{ secrets.DOCKER_PUSH_TOKEN }} registry: ghcr.io workdir: webapp + buildargs: API_URI docker-push-restapi: name: Push restapi Docker Image to GitHub Packages - env: - MONGO_DB_URI: ${{ secrets.MONGO_DB_URI }} - SECRET_SALT: ${{ secrets.SECRET_SALT }} - SECRET: ${{ secrets.SECRET }} - PRUEBA: ${{ secrets.PRUEBA }} runs-on: ubuntu-latest - needs: [unit-test-webapp, unit-test-restapi] + needs: [unit-test-restapi] # needs: [e2e-tests] steps: - uses: actions/checkout@v2 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@3.04 + env: + DB_URI: ${{ secrets.MONGO_DB_URI }} + PASS_SALT: ${{ secrets.SECRET_SALT }} + PASS: ${{ secrets.SECRET }} with: name: arquisoft/dede_es4b/restapi username: ${{ github.actor }} password: ${{ secrets.DOCKER_PUSH_TOKEN }} registry: ghcr.io workdir: restapi + buildargs: DB_URI, PASS_SALT, PASS deploy: name: Deploy over SSH runs-on: ubuntu-latest diff --git a/restapi/.env b/restapi/.env deleted file mode 100644 index 028c085..0000000 --- a/restapi/.env +++ /dev/null @@ -1,4 +0,0 @@ -MONGO_DB_URI = mongodb+srv://dede_es4b:dede_es4b_pass.DFSS@cluster0.v4ply.mongodb.net/shop?retryWrites=true&w=majority -SECRET_SALT = 'saltSecreta' -SECRET = 'sicreto' -PRUEBA = prueba \ No newline at end of file diff --git a/restapi/Dockerfile b/restapi/Dockerfile index 54b2573..0bc2404 100644 --- a/restapi/Dockerfile +++ b/restapi/Dockerfile @@ -5,8 +5,13 @@ WORKDIR /app #Install the dependencies RUN npm install -ENV MONGO_DB_URI=$MONGO_DB_URI -ENV SECRET_SALT=$SECRET_SALT -ENV SECRET=$SECRET +ARG DB_URI="http://localhost" +ENV MONGO_DB_URI=$DB_URI + +ARG PASS_SALT="" +ENV SECRET_SALT=$PASS_SALT + +ARG PASS="" +ENV SECRET=$PASS CMD [ "npm", "start" ] \ No newline at end of file diff --git a/restapi/server.ts b/restapi/server.ts index 5879281..c1ae1f5 100644 --- a/restapi/server.ts +++ b/restapi/server.ts @@ -14,7 +14,7 @@ const app: Application = express(); const port = 5000; const options: cors.CorsOptions = { - origin: ['http://localhost:3000','http://dedethlon.francecentral.cloudapp.azure.com:3000/'] + origin: ['http://localhost:3000','http://dedethlon.francecentral.cloudapp.azure.com:3000'] }; app.use(cors(options));