From f9c5e1a2f4493d6aa600e169976a32715a3df6e8 Mon Sep 17 00:00:00 2001 From: dskvr Date: Tue, 22 Feb 2022 23:09:58 +0100 Subject: [PATCH 1/7] Lint only lints now and added deploy workflow --- .github/workflows/deploy.yml | 73 ++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 31 ++++++++------- 2 files changed, 88 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f009ccb --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,73 @@ +name: Deploy Packages & Docs + +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + +env: + PROD_BRANCH: master + +on: + push: + branches: [${{ PROD_BRANCH }}] + pull_request: + branches: [${{ PROD_BRANCH }}] + types: [closed] + workflow_dispatch: + +jobs: + docker: + name: "Build Docker" + runs-on: ubuntu-latest + permissions: + contents: write + packages: read + pull-requests: read + env: + DOCKER_REGISTRY: ghcr.io/alien-worlds + FILLER_FLAGS: + steps: + - uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Building dependencies + run: docker compose run api yarn + + ghp_deploy: + name: "Deploy to GHP" + depends_on: [docker] + if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.base_ref == '${{ PROD_BRANCH }}' + runs-on: ubuntu-latest + permissions: + contents: write + packages: read + pull-requests: read + steps: + - name: Generating OpenAPI definition + run: docker compose -f docker-compose.yml -f docker-compose.apigen.yml run apigen && docker compose down + + - name: Generating Redoc + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./openapi + publish_branch: docs + + packages_deploy: + name: "Deploy to GHP" + depends_on: [docker] + if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.base_ref == '${{ PROD_BRANCH }}' + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + pull-requests: read + steps: + - name: Pushing Images to Registry + run: docker compose push diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7bc7c86..f5edc00 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,19 +1,19 @@ -name: lint +name: Lint concurrency: - group: lint-${{ github.ref }} + group: build-${{ github.ref }} cancel-in-progress: true on: push: - branches: [master] + branches: [master, develop] pull_request: - branches: [master] - + branches: [master, develop] workflow_dispatch: jobs: - lint: + docker: + name: "Build Docker" runs-on: ubuntu-latest permissions: contents: write @@ -35,18 +35,17 @@ jobs: - name: Building dependencies run: docker compose run api yarn + formatting: + name: "Code Formatting" + depends_on: [docker] + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + pull-requests: read + steps: - name: Running ESLint run: docker compose run api yarn lint-es - name: Running Prettier run: docker compose run api yarn lint-prettier - - - name: Generating OpenAPI definition - run: docker compose -f docker-compose.yml -f docker-compose.apigen.yml run apigen && docker compose down - - - name: Generating Redoc - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./openapi - publish_branch: docs From 541cd279ad1bd3f96f5b54a34f3315f28cfe82ec Mon Sep 17 00:00:00 2001 From: dskvr Date: Tue, 22 Feb 2022 23:15:56 +0100 Subject: [PATCH 2/7] moved env in deploy, changed cooncurrency group in lint --- .github/workflows/deploy.yml | 12 +++++++++--- .github/workflows/lint.yml | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f009ccb..7c44da0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,6 +5,8 @@ concurrency: cancel-in-progress: true env: + DOCKER_REGISTRY: ghcr.io/alien-worlds + FILLER_FLAGS: PROD_BRANCH: master on: @@ -23,9 +25,6 @@ jobs: contents: write packages: read pull-requests: read - env: - DOCKER_REGISTRY: ghcr.io/alien-worlds - FILLER_FLAGS: steps: - uses: actions/checkout@v2 @@ -69,5 +68,12 @@ jobs: packages: write pull-requests: read steps: + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Pushing Images to Registry run: docker compose push diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f5edc00..61fe6c1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,7 @@ name: Lint concurrency: - group: build-${{ github.ref }} + group: lint-${{ github.ref }} cancel-in-progress: true on: @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write - packages: write + packages: read pull-requests: read env: DOCKER_REGISTRY: ghcr.io/alien-worlds From 6cf0347ee4344551b045b53419472433122d5ce2 Mon Sep 17 00:00:00 2001 From: dskvr Date: Tue, 22 Feb 2022 23:26:00 +0100 Subject: [PATCH 3/7] flatten workflow, remove separate jobs --- .github/workflows/deploy.yml | 36 ++++++------------------------------ .github/workflows/lint.yml | 11 +---------- 2 files changed, 7 insertions(+), 40 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7c44da0..f9f7bbd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,9 +21,10 @@ jobs: docker: name: "Build Docker" runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.base_ref == '${{ PROD_BRANCH }}' permissions: contents: write - packages: read + packages: write pull-requests: read steps: - uses: actions/checkout@v2 @@ -38,16 +39,9 @@ jobs: - name: Building dependencies run: docker compose run api yarn - ghp_deploy: - name: "Deploy to GHP" - depends_on: [docker] - if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.base_ref == '${{ PROD_BRANCH }}' - runs-on: ubuntu-latest - permissions: - contents: write - packages: read - pull-requests: read - steps: + - name: Pushing Images to Registry + run: docker compose push + - name: Generating OpenAPI definition run: docker compose -f docker-compose.yml -f docker-compose.apigen.yml run apigen && docker compose down @@ -58,22 +52,4 @@ jobs: publish_dir: ./openapi publish_branch: docs - packages_deploy: - name: "Deploy to GHP" - depends_on: [docker] - if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.base_ref == '${{ PROD_BRANCH }}' - runs-on: ubuntu-latest - permissions: - contents: write - packages: write - pull-requests: read - steps: - - name: Log in to the Container registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Pushing Images to Registry - run: docker compose push +# Todo Deploy API :D diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 61fe6c1..7cd74c0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,7 +13,7 @@ on: jobs: docker: - name: "Build Docker" + name: "Build and Lint" runs-on: ubuntu-latest permissions: contents: write @@ -35,15 +35,6 @@ jobs: - name: Building dependencies run: docker compose run api yarn - formatting: - name: "Code Formatting" - depends_on: [docker] - runs-on: ubuntu-latest - permissions: - contents: write - packages: write - pull-requests: read - steps: - name: Running ESLint run: docker compose run api yarn lint-es From f8dafd00e9e882c06f1d5ddbfab0dbbd11dd06a2 Mon Sep 17 00:00:00 2001 From: dskvr Date: Tue, 22 Feb 2022 23:27:00 +0100 Subject: [PATCH 4/7] adjust step name --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f9f7bbd..52144b8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -45,11 +45,11 @@ jobs: - name: Generating OpenAPI definition run: docker compose -f docker-compose.yml -f docker-compose.apigen.yml run apigen && docker compose down - - name: Generating Redoc + - name: Deploying Redoc uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./openapi publish_branch: docs -# Todo Deploy API :D +# Todo Deploy API :D From bbef117b6b7388c5c3ef8b504bc2eb17d626d246 Mon Sep 17 00:00:00 2001 From: dskvr Date: Tue, 22 Feb 2022 23:31:56 +0100 Subject: [PATCH 5/7] remove global env from on member to validate and fix conditional --- .github/workflows/deploy.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 52144b8..6df9dcf 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,21 +7,19 @@ concurrency: env: DOCKER_REGISTRY: ghcr.io/alien-worlds FILLER_FLAGS: - PROD_BRANCH: master on: push: - branches: [${{ PROD_BRANCH }}] + branches: [master] pull_request: - branches: [${{ PROD_BRANCH }}] + branches: [master] types: [closed] - workflow_dispatch: jobs: docker: name: "Build Docker" runs-on: ubuntu-latest - if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.base_ref == '${{ PROD_BRANCH }}' + if: ((github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)) permissions: contents: write packages: write From f101d02690036ad2617a4b5c243648b5586141fb Mon Sep 17 00:00:00 2001 From: dskvr Date: Tue, 22 Feb 2022 23:33:12 +0100 Subject: [PATCH 6/7] update comment --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6df9dcf..90c7754 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -50,4 +50,4 @@ jobs: publish_dir: ./openapi publish_branch: docs -# Todo Deploy API :D +#TODO: Deploy API to Production From a7b33092f54916daaf9646a668c89e3dc575769e Mon Sep 17 00:00:00 2001 From: dskvr Date: Tue, 22 Feb 2022 23:40:18 +0100 Subject: [PATCH 7/7] remove needless parenthesis --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 90c7754..ddbde6e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,7 +19,7 @@ jobs: docker: name: "Build Docker" runs-on: ubuntu-latest - if: ((github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)) + if: (github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) permissions: contents: write packages: write