Build main every 8 hours for dev #1702
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2024 Flant JSC | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: Build main every 8 hours for dev | |
| env: | |
| MODULES_REGISTRY: ${{ vars.DEV_REGISTRY }} | |
| CI_COMMIT_REF_NAME: ${{ github.ref_name }} | |
| MODULES_MODULE_NAME: ${{ vars.MODULE_NAME }} | |
| MODULES_MODULE_SOURCE: ${{ vars.DEV_MODULE_SOURCE }} | |
| MODULES_REGISTRY_LOGIN: ${{ vars.DEV_MODULES_REGISTRY_LOGIN }} | |
| MODULES_REGISTRY_PASSWORD: ${{ secrets.DEV_MODULES_REGISTRY_PASSWORD }} | |
| SOURCE_REPO: "${{secrets.SOURCE_REPO}}" | |
| SOURCE_REPO_GIT: "${{secrets.SOURCE_REPO_GIT}}" | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 */8 * * *" | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| build_branches: | |
| name: Build main | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| branch: [main] | |
| steps: | |
| - name: Setup Docker config | |
| run: | | |
| echo "DOCKER_CONFIG=$(mktemp -d)" >> $GITHUB_ENV | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ matrix.branch }} | |
| - name: Set vars | |
| id: modules_module_tag | |
| run: | | |
| if [[ "${{ github.ref_name }}" == 'main' ]]; then | |
| MODULES_MODULE_TAG="${{ github.ref_name }}" | |
| elif [[ "${{ github.ref_name }}" =~ ^release-[0-9]+\.[0-9]+ ]]; then | |
| MODULES_MODULE_TAG="${{ github.ref_name }}" | |
| elif [[ -n "${{ github.event.pull_request.number }}" ]]; then | |
| MODULES_MODULE_TAG="pr${{ github.event.pull_request.number }}" | |
| elif [[ -n "${{ github.event.inputs.pr_number }}" ]]; then | |
| MODULES_MODULE_TAG="pr${{ github.event.inputs.pr_number }}" | |
| else | |
| echo "::error title=Module image tag is required::Can't detect module tag from workflow context. Dev build uses branch name as tag for main and release branches, and PR number for builds from pull requests. Check workflow for correctness." | |
| exit 1 | |
| fi | |
| echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_OUTPUT" | |
| - name: Remove unwanted software | |
| uses: ./.github/actions/remove-unwanted-software | |
| - uses: deckhouse/modules-actions/setup@v2 | |
| with: | |
| registry: ${{ vars.DEV_REGISTRY }} | |
| registry_login: ${{ vars.DEV_MODULES_REGISTRY_LOGIN }} | |
| registry_password: ${{ secrets.DEV_MODULES_REGISTRY_PASSWORD }} | |
| - uses: deckhouse/modules-actions/build@v4 | |
| with: | |
| module_source: ${{ vars.DEV_MODULE_SOURCE}} | |
| module_name: ${{ vars.MODULE_NAME }} | |
| module_tag: ${{ steps.modules_module_tag.outputs.MODULES_MODULE_TAG }} | |
| source_repo: ${{secrets.SOURCE_REPO_GIT}} | |
| source_repo_ssh_key: ${{ secrets.SOURCE_REPO_SSH_KEY }} | |
| - name: Cleanup Docker config | |
| run: | | |
| rm -rf $DOCKER_CONFIG |