From 321c222973878f041f3a22f6b764df9c3e6ab09c Mon Sep 17 00:00:00 2001 From: "Freddy R. Laffita Almaguer" Date: Mon, 8 Jan 2024 05:41:29 -0500 Subject: [PATCH] Updating deployment actions --- .github/workflows/main.yaml | 66 ------------------------------------- .github/workflows/main.yml | 61 ++++++++++++++++++++++++++++++++++ Dockerfile | 4 +-- 3 files changed, 63 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/main.yaml create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index 25c7faf78e..0000000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,66 +0,0 @@ -name: main - -on: - push: - branches: - - 'master' - tags: - - 'v*' - pull_request: - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: 1.16 - - uses: actions/setup-node@v2 - with: - node-version: '14' - - run: npm i -g commitlint - - run: make lint - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: 1.16 - - uses: actions/setup-node@v2 - with: - node-version: '14' - - run: make test - release: - runs-on: ubuntu-latest - needs: [lint, test] - if: startsWith(github.event.ref, 'refs/tags/v') - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: actions/setup-go@v2 - with: - go-version: 1.16 - - uses: actions/setup-node@v2 - with: - node-version: '14' - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Build fronetend - run: make build-frontend - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..8f3e3a4e24 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,61 @@ +name: Filebrowser docker image + +on: + push: + branches: + - '**' + tags: [ 'v*' ] + pull_request: + branches: + - 'master' + +jobs: + generate-filebrowser-image: + runs-on: ubuntu-latest + steps: + - name: Determine Build Environment + id: set-env + run: | + if ${{ github.event_name == 'push' && github.ref_name != 'master' }}; then + echo "DEV environment" + echo "ENV_VERSION=v10-dev" >> $GITHUB_ENV + elif ${{ github.event_name == 'pull_request' && github.base_ref == 'master' }}; then + echo "QA environment" + echo "ENV_VERSION=v10-qa" >> $GITHUB_ENV + elif ${{ github.event_name == 'push' && github.ref_name == 'master'}}; then + echo "RC environment" + echo "ENV_VERSION=v10-rc" >> $GITHUB_ENV + elif ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}; then + echo "PROD environment" + echo "ENV_VERSION=v10" >> $GITHUB_ENV + fi + - name: Check out code into the right branch + uses: actions/checkout@v4 + - uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Build frontend + run: make build-frontend + - name: Set up Go 1.x + uses: actions/setup-go@v4 + with: + go-version: ^1.20 + id: go + - name: Build Binary + run: go build -o "filebrowser" -v . + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: utmstack + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push the Image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ghcr.io/utmstack/filebrowser/filebrowser:${{ env.ENV_VERSION }} + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c0284603fb..e20333a6e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,10 @@ RUN apt install -y ca-certificates sendmail curl HEALTHCHECK --start-period=2s --interval=5s --timeout=3s \ CMD curl -f http://localhost:9091/health || exit 1 -VOLUME /srv - COPY .docker.json /.filebrowser.json COPY filebrowser /filebrowser COPY run.sh /run.sh +RUN chmod +x /run.sh + ENTRYPOINT [ "/run.sh" ]