From 031fc447e0cc534c0e91a37f3e89421f0be771c0 Mon Sep 17 00:00:00 2001 From: Vitor Carvalho Date: Wed, 15 Jun 2022 17:45:11 +0100 Subject: [PATCH] Added automation to fetch latest tag --- .github/workflows/continuous-deployment.yml | 5 -- .github/workflows/manual-deployment.yml | 48 ++++++++++++------- .github/workflows/update-version.yml | 53 +++++++++++++++++++++ Dockerfile | 2 +- 4 files changed, 85 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/update-version.yml diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index 5cc8951..64c3fce 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -1,10 +1,5 @@ name: Continuous Deployment -on: - push: - branches: - - master - jobs: deploy: runs-on: ubuntu-latest diff --git a/.github/workflows/manual-deployment.yml b/.github/workflows/manual-deployment.yml index 57c6259..7009c15 100644 --- a/.github/workflows/manual-deployment.yml +++ b/.github/workflows/manual-deployment.yml @@ -2,30 +2,44 @@ name: Manual Deployment on: workflow_dispatch: + schedule: + - cron: '59 23 * * *' jobs: - deploy: + release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: - fetch-depth: 1 + fetch-depth: 0 - - name: Login to Docker Registry - uses: docker/login-action@v1 + - id: latest_tag + uses: thebritican/fetch-latest-release@v2.0.0 with: - registry: registry.moveyourdigital.dev - username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} - password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} + github_token: ${{ github.token }} + repo_path: actions/runner - - name: Build and Push to Docker Registry - uses: docker/build-push-action@v2 - with: - context: . - platforms: linux/amd64 - push: true - tags: registry.moveyourdigital.dev/github/actions-runner:latest + - id: output + run: "echo 'RUNNER_VERSION=\"${{ steps.latest_tag.outputs.tag_name }}\"'" + + # - name: Update Dockerfile RUNNER_VERSION org + # run: sed -i.bak "s/RUNNER_VERSION.*/RUNNER_VERSION=\"${steps.latest_tag.outputs.}\"/" Dockerfile + + # - name: Login to Docker Registry + # uses: docker/login-action@v1 + # with: + # registry: registry.moveyourdigital.dev + # username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} + # password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} + + # - name: Build and Push to Docker Registry + # uses: docker/build-push-action@v2 + # with: + # context: . + # platforms: linux/amd64 + # push: true + # tags: registry.moveyourdigital.dev/github/actions-runner:latest - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} + # - name: Image digest + # run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml new file mode 100644 index 0000000..10e1e5f --- /dev/null +++ b/.github/workflows/update-version.yml @@ -0,0 +1,53 @@ +name: Update Version + +on: + workflow_dispatch: + schedule: + - cron: '59 23 * * *' + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - id: fetch-latest-release + uses: thebritican/fetch-latest-release@v2.0.0 + with: + github_token: ${{ github.token }} + repo_path: actions/runner + + - id: commit + run: | + TAG=${{ steps.fetch-latest-release.outputs.tag_name }} + sed -i.bak "s/RUNNER_VERSION.*/RUNNER_VERSION=\"${TAG:1}\"/" Dockerfile + if [[ `git status -uno --porcelain` ]]; then + git config --global user.name 'lightningspirit [Automated 🤖]' + git config --global user.email 'lightningspirit@users.noreply.github.com' + git commit -am "Bump to $TAG" + git push + fi + + # - name: Update Dockerfile RUNNER_VERSION org + # run: sed -i.bak "s/RUNNER_VERSION.*/RUNNER_VERSION=\"${steps.latest_tag.outputs.}\"/" Dockerfile + + # - name: Login to Docker Registry + # uses: docker/login-action@v1 + # with: + # registry: registry.moveyourdigital.dev + # username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} + # password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} + + # - name: Build and Push to Docker Registry + # uses: docker/build-push-action@v2 + # with: + # context: . + # platforms: linux/amd64 + # push: true + # tags: registry.moveyourdigital.dev/github/actions-runner:latest + + # - name: Image digest + # run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index 09e79b4..ec3af20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:21.04 # set the github runner version -ARG RUNNER_VERSION="2.293.0" +ARG RUNNER_VERSION="2.287.0" ENV TZ=Europe/Lisbon RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone