Skip to content

Commit

Permalink
añadidos variables de entorno de secrets
Browse files Browse the repository at this point in the history
arreglado cors

Quitado .env

Action paralelo y mas env

Arreglos secrets
  • Loading branch information
tsmanuelanton committed May 3, 2022
1 parent 70fdddb commit 05e5612
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/asw2122.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/[email protected]
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/[email protected]
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
Expand Down
4 changes: 0 additions & 4 deletions restapi/.env

This file was deleted.

11 changes: 8 additions & 3 deletions restapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
2 changes: 1 addition & 1 deletion restapi/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 05e5612

Please sign in to comment.