Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Github Actions CI workflow
Naive Jenkinsfile to GH Actions workflow Add naive ci-cd pipeline Update ci pipeline diff --git a/.github/workflows/ci-cd-pipeline.yml b/.github/workflows/ci-cd-pipeline.yml index ba2ec6b..a86e7d1 100644 --- a/.github/workflows/ci-cd-pipeline.yml +++ b/.github/workflows/ci-cd-pipeline.yml @@ -1,81 +1,32 @@ -name: CI/CD Pipeline +name: ci on: - push + push: + branches: + - '*' + # - 'main' jobs: - build: + docker: runs-on: ubuntu-latest - - env: - repository: guppy_server - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set version - id: set-version - run: echo "::set-output name=version::$(date -d @$(git log -1 --format=%at) +%Y%m%d%Z%H%M)-${{ github.ref_name }}" - - - name: Set datetime - id: set-datetime - run: echo "::set-output name=datetime::$(date -d @$(git log -1 --format=%at) +%Y%m%d%Z%H%M)" - - - name: Build conda-env docker image - run: docker build --target conda-env -t ghcr.io/${{ github.repository_owner }}/${{ env.repository }}_conda-env:latest-${{ github.ref_name }} server - - - name: Build docker image - run: | - docker build -t ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:latest-${{ github.ref_name }} server - echo "::set-output name=dockerImage::ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:latest-${{ github.ref_name }}" - - - name: Run unittests - run: docker run --rm ${{ steps.build.outputs.dockerImage }} /opt/guppy/server/conda-env/bin/python -m unittest discover -s server -v - - # - name: Login to GitHub Container Registry - # run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - # - name: Push docker image to registry - # run: | - # docker push ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:${{ env.version }} - # if [[ ${{ github.ref_name }} =~ ^(main|master)$ ]]; then - # docker push ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:latest - # docker push ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:${{ env.datetime }} - # fi - # if [[ ${{ github.ref }} =~ refs/tags/ ]]; then - # tag="${{ github.ref#refs/tags/ }}" - # docker push ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:${tag} - # else - # docker push ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:latest-${{ github.ref_name }} - - # - name: Cleanup - # run: | - # docker image rm ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:${{ env.version }} - # if [[ ${{ github.ref_name }} =~ ^(main|master)$ ]]; then - # docker image rm ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:latest - # docker image rm ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:${{ env.datetime }} - # fi - # if [[ ${{ github.ref }} =~ refs/tags/ ]]; then - # tag="${{ github.ref#refs/tags/ }}" - # docker image rm ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:${tag} - # else - # docker image rm ghcr.io/${{ github.repository_owner }}/${{ env.repository }}:latest-${{ github.ref_name }} - - # - name: Update services - # if: github.ref_name == 'develop' || github.ref_name == 'main' || github.ref_name == 'master' - # run: | - # deploy_branch="" - # if [[ ${{ github.ref_name }} == 'develop' ]]; then - # deploy_branch=${{ env.deploy_test_branch }} - # elif [[ ${{ github.ref_name }} =~ ^(main|master)$ ]]; then - # deploy_branch=${{ env.deploy_prod_branch }} - # fi - # if [ -z "$deploy_branch" ]; then - # echo "Skipping service update: $deploy_project/$deploy_branch does not exist yet!" - # else - # echo "Updating services for $deploy_project/$deploy_branch" - # # Add the actual service update logic here - - # - name: Clean up - # run: rm -rf ${{ github.workspace }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: user/app:latest + context: ./server + file: ./server/Dockerfile \ No newline at end of file Checkout code as first GH-CI workflow step Add corect dockerhub tag Push to dockerhub organisation vitobelgium Add docker action cache Add latest/latest-dev tag Add support for other branches (integration mode)
- Loading branch information