From 21922db6dcbed56e1630bfbdb1de4a712aa7fd5b Mon Sep 17 00:00:00 2001 From: gthvmt Date: Tue, 19 Dec 2023 15:47:11 +0000 Subject: [PATCH] :construction_worker: update github workflows add a build check for all pull requests to and automatically build and push the containerfile to the ghcr on all pushs to development and master. Other pipelines do not wait for the container to be pushed which means that they may have to be manually restarted if they fail due to an old container image. --- .devcontainer/Containerfile | 2 +- .github/workflows/push_container.yaml | 28 +++++++++++++++++++++ .github/workflows/release.yaml | 8 +++++- .github/workflows/test_build.yaml | 36 +++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/push_container.yaml create mode 100644 .github/workflows/test_build.yaml diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile index 5ffc978..7476f77 100644 --- a/.devcontainer/Containerfile +++ b/.devcontainer/Containerfile @@ -1,5 +1,5 @@ FROM rust:bookworm - +# ARG VERSION="stable" ARG FLUTTER_URL="https://github.com/flutter/flutter" ARG ANDROID_SDK_TOOLS_VERSION=9477386 diff --git a/.github/workflows/push_container.yaml b/.github/workflows/push_container.yaml new file mode 100644 index 0000000..60e9305 --- /dev/null +++ b/.github/workflows/push_container.yaml @@ -0,0 +1,28 @@ +name: Push container +on: + push: + branches: + - development + - master + paths: + - '.devcontainer/Containerfile' + +jobs: + push: + name: Push container image + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{secrets.TOKEN}} + - name: 'Login to GitHub Container Registry' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{github.repository_owner}} + password: ${{secrets.TOKEN}} + - name: Build and push Docker image + run: | + docker build . -f ./.devcontainer/Containerfile -t ghcr.io/${{ github.repository_owner }}/7tv4wa-dev:${{ github.head_ref || github.ref_name }} -t ghcr.io/${{ github.repository_owner }}/7tv4wa-dev:latest + docker push ghcr.io/${{ github.repository_owner }}/7tv4wa-dev --all-tags \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d6203e5..f403ccf 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,7 +14,13 @@ jobs: name: Create release runs-on: ubuntu-latest container: - image: ghcr.io/gthvmt/7tv4wa-dev + image: >- + ghcr.io/${{ github.repository_owner }}/7tv4wa-dev:${{ + (github.event_name == 'pull_request' && + (github.event.pull_request.base.ref == 'development' || + github.event.pull_request.base.ref == 'master')) && + github.event.pull_request.base.ref || + 'latest' }} credentials: username: ${{ github.actor }} password: ${{ secrets.TOKEN }} diff --git a/.github/workflows/test_build.yaml b/.github/workflows/test_build.yaml new file mode 100644 index 0000000..714a254 --- /dev/null +++ b/.github/workflows/test_build.yaml @@ -0,0 +1,36 @@ +name: Build +on: + pull_request: + types: + - opened + - synchronize + +permissions: + contents: read + pull-requests: read + +jobs: + build: + name: Build APK + runs-on: ubuntu-latest + container: + image: >- + ghcr.io/${{ github.repository_owner }}/7tv4wa-dev:${{ + (github.event_name == 'pull_request' && + (github.event.pull_request.base.ref == 'development' || + github.event.pull_request.base.ref == 'master')) && + github.event.pull_request.base.ref || + 'latest' }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.TOKEN }} + env: + GITHUB_TOKEN: ${{secrets.TOKEN}} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: 'recursive' + token: ${{secrets.TOKEN}} + - name: Build apk + run: chmod +x .github/workflows/*.sh && .github/workflows/build.sh \ No newline at end of file