From a80595f1cb299cb64880d8d3bead934f67e523af Mon Sep 17 00:00:00 2001 From: Adrien Beaudouin Date: Wed, 14 Aug 2024 16:56:45 +0200 Subject: [PATCH] add tag only --- .vscode/settings.json | 7 +++++++ deploy.yaml | 33 +++++++++++++++++++++++++++++++++ docker/action.yaml | 10 ---------- 3 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 deploy.yaml diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ceed3ea --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "yaml.schemas": { + "https://raw.githubusercontent.com/number5/cloud-init/main/cloudinit/config/schemas/schema-cloud-config-v1.json": "cloud-config.yml", + "file:///c%3A/Users/Adrien/.vscode/extensions/atlassian.atlascode-3.0.3/resources/schemas/pipelines-schema.json": "bitbucket-pipelines.yml", + "https://json.schemastore.org/github-workflow.json": "file:///c%3A/Users/Adrien/Projects/okami101/actions/deploy.yaml" + } +} \ No newline at end of file diff --git a/deploy.yaml b/deploy.yaml new file mode 100644 index 0000000..d74a8de --- /dev/null +++ b/deploy.yaml @@ -0,0 +1,33 @@ +name: Docker build test + +on: + workflow_call: + registry: + description: "Server address of Docker registry." + default: ${{ vars.CONTAINER_REGISTRY }} + username: + description: "Username used to log against the Docker registry" + default: ${{ vars.CONTAINER_REGISTRY_USERNAME }} + password: + description: "Password or personal access token used to log against the Docker registry" + required: true + +jobs: + deploy: + runs-on: ubuntu-latest + if: ${{ startsWith(gitea.ref, 'refs/tags/v') }} + steps: + - uses: https://gitea.okami101.io/okami101/actions/docker@main + with: + registry: ${{ inputs.registry }} + username: ${{ inputs.username }} + password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + - name: Push tags + shell: bash + if: ${{ startsWith(gitea.ref, 'refs/tags/v') }} + env: + DOCKER_IMAGE: ${{ inputs.registry }}/${{ gitea.repository }} + run: | + docker tag $DOCKER_IMAGE:main $DOCKER_IMAGE:latest + docker tag $DOCKER_IMAGE:main $DOCKER_IMAGE:${{ steps.meta.outputs.version }} + docker push -a $DOCKER_IMAGE diff --git a/docker/action.yaml b/docker/action.yaml index 26790fc..6c5f9cd 100644 --- a/docker/action.yaml +++ b/docker/action.yaml @@ -25,18 +25,8 @@ runs: username: ${{ inputs.username }} password: ${{ inputs.password }} - uses: docker/build-push-action@v6 - if: ${{ !startsWith(gitea.ref, 'refs/tags/v') }} with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - name: Push tags - shell: bash - if: ${{ startsWith(gitea.ref, 'refs/tags/v') }} - env: - DOCKER_IMAGE: ${{ inputs.registry }}/${{ gitea.repository }} - run: | - docker tag $DOCKER_IMAGE:main $DOCKER_IMAGE:latest - docker tag $DOCKER_IMAGE:main $DOCKER_IMAGE:${{ steps.meta.outputs.version }} - docker push -a $DOCKER_IMAGE