From 8ee4748605160109c696edf2f55af1b860bf4c5b Mon Sep 17 00:00:00 2001 From: dhruveshb-mecha <104081346+dhruveshb-mecha@users.noreply.github.com> Date: Tue, 12 Dec 2023 10:04:58 -0500 Subject: [PATCH 1/2] self-hosted-workflow-runner.yml --- .../workflows/self-hosted-workflow-runner.yml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/self-hosted-workflow-runner.yml diff --git a/.github/workflows/self-hosted-workflow-runner.yml b/.github/workflows/self-hosted-workflow-runner.yml new file mode 100644 index 0000000..5c5fa25 --- /dev/null +++ b/.github/workflows/self-hosted-workflow-runner.yml @@ -0,0 +1,42 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Publish Docker image + +on: push + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: mechaorg/mecha-image-core + + - name: Build and push Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + \ No newline at end of file From 2c8abf543749b7145760420cd6f6350de895d4c8 Mon Sep 17 00:00:00 2001 From: dhruveshb-mecha <104081346+dhruveshb-mecha@users.noreply.github.com> Date: Tue, 12 Dec 2023 10:08:48 -0500 Subject: [PATCH 2/2] self hosted runner added --- .../workflows/self-hosted-workflow-runner.yml | 62 ++++++++----------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/.github/workflows/self-hosted-workflow-runner.yml b/.github/workflows/self-hosted-workflow-runner.yml index 5c5fa25..75e7047 100644 --- a/.github/workflows/self-hosted-workflow-runner.yml +++ b/.github/workflows/self-hosted-workflow-runner.yml @@ -1,42 +1,32 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. +# write a code that create folder on server and it has one text file hello.txt with data "hello from self hosetd runner." -# GitHub recommends pinning actions to a commit SHA. -# To get a newer version, you will need to update the SHA. -# You can also reference a tag or branch, but the action may change without warning. +name: Mecha-os Build Runner -name: Publish Docker image - -on: push +on: + push: + branches: + - main jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest + build: + runs-on: self-hosted + steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: Log in to Docker Hub - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: mechaorg/mecha-image-core - - - name: Build and push Docker image - uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + - name: Pull Docker Image + run: docker pull mechaorg/mecha-image-core:latest + + - name: Run Docker Image + run: docker run -v /home/mecha/volume/mechaos/build:/home/mecha/build -v /home/mecha/volume/mechaos/download:/home/mecha/downloads mechaorg/mecha-image-core + + + - name: Set up S3cmd cli tool + uses: s3-actions/s3cmd@v1.5.0 with: - context: . - file: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - \ No newline at end of file + provider: aws # default is linode + region: "us-east-2" + access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} + secret_key: ${{ secrets.S3_SECRET_KEY }} + + - name: Sync Assets to S3Bucket + run: | + s3cmd sync --recursive /home/mecha/volume/mechaos/build/tmp/deploy/images ${{ secrets.S3_BUCKET_PATH }} \ No newline at end of file