diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index acbaf0e8..5547a7ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,6 +51,7 @@ jobs: with: # network=host driver-opt needed to push to local registry driver-opts: network=host + platforms: linux/amd64,linux/arm64 - name: Build and export oss image uses: docker/build-push-action@v5 with: @@ -58,6 +59,7 @@ jobs: context: . tags: localhost:5000/nginx-s3-gateway , localhost:5000/nginx-s3-gateway:oss push: true + platforms: linux/amd64,linux/arm64 # Since the above build pushes to the registry only now we load it locally so we can save it # It's not possible with push and save in one go. - name: Load image oss @@ -81,6 +83,7 @@ jobs: tags: localhost:5000/nginx-s3-gateway:latest-njs-oss push: false outputs: type=docker,dest=/tmp/latest-njs.tar + platforms: linux/amd64,linux/arm64 build-contexts: | nginx-s3-gateway=docker-image://localhost:5000/nginx-s3-gateway:oss - name: Upload artifact - latest-njs @@ -97,6 +100,7 @@ jobs: tags: localhost:5000/nginx-s3-gateway:unprivileged push: false outputs: type=docker,dest=/tmp/unprivileged.tar + platforms: linux/amd64,linux/arm64 build-contexts: | nginx-s3-gateway=docker-image://localhost:5000/nginx-s3-gateway:oss - name: Upload artifact - unprivileged @@ -213,11 +217,56 @@ jobs: - name: Run tests - stable njs version - unprivileged process run: ./test.sh --unprivileged --type oss - # build_and_deploy: - # runs-on: ubuntu-latest + tag-and-push: + runs-on: ubuntu-latest + needs: [test-oss, test-latest-njs, test-unprivileged] + + if: | + github.ref == 'refs/heads/master' || + github.ref == 'refs/heads/main' + steps: + - name: Get current date + id: date + run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT + - name: Configure Github Package Registry + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin + + - name: Download artifact - oss + uses: actions/download-artifact@v3 + with: + name: oss + path: /tmp + - name: Download artifact - latest-njs + uses: actions/download-artifact@v3 + with: + name: latest-njs + path: /tmp + - name: Download artifact - unprivileged + uses: actions/download-artifact@v3 + with: + name: unprivileged + path: /tmp + + - name: Load and retag oss image [oss] + run: | + docker load --input /tmp/oss.tar + docker tag localhost:5000/nginx-s3-gateway docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-${{ steps.date.outputs.date }}-new-build-test + docker tag localhost:5000/nginx-s3-gateway docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-new-build-test + - name: Push container image to github [oss date] + run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-${{ steps.date.outputs.date }}-new-build-test + - name: Push container image to github [oss latest] + run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-new-build-test + - name: Load and retag oss image [latest-njs-oss] + run: | + docker load --input /tmp/latest-njs.tar + docker tag localhost:5000/nginx-s3-gateway::latest-njs-oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-${{ steps.date.outputs.date }}-new-build-test + docker tag localhost:5000/nginx-s3-gateway::latest-njs-oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-new-build-test + - name: Push container image to github [latest-njs-oss date] + run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-${{ steps.date.outputs.date }}-new-build-test + - name: Push container image to github [latest-njs-oss] + run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-new-build-test + - # if: github.ref == 'refs/heads/master' - # steps: # # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it # - uses: actions/checkout@v2